[Python-Dev] Wrapping up 'dynamic attribute' discussion (original) (raw)

Greg Falcon veloso at verylowsodium.com
Fri Feb 16 05:00:01 CET 2007


On 2/15/07, Anthony Baxter <anthony at interlink.com.au> wrote:

On Friday 16 February 2007 09:08, Ben North wrote: > The wrapper class idea was left > open as a possibility for a future PEP.

A good first step would be to contribute something like this to the Python Cookbook, if it isn't already there.

I could not find such a class in the cookbook. (That's not to say there's not one there that I missed.)

Because I think attrview() should happen, I submitted a recipe to the Python Cookbook. While it awaits editor approval, I have it posted at http://www.verylowsodium.com/attrview.py .

One possibly controversial design choice here: since there is no guaranteed way to enumerate attributes in the face of getattr and friends, my version of attrview() does not provide iteration or any other operation that assumes object attributes can be enumerated. Therefore, it technically does not implement a mapping.

Once Python grows a dir special method, it's possible I could be convinced this is the wrong choice, but I'm not sure of that.

Greg F



More information about the Python-Dev mailing list