properties + types, implementing meta-class desciptors elegantly?

Mike C. Fletcher mcfletch at rogers.com
Fri Jul 18 18:00:40 EDT 2003


Ian Bicking wrote:

...

>>which would seem to suggest that the only way to use the regular 
>>descriptors would be to do the (annoying) '_'+name thing so that there's 
>>a proliferation of names in the class (which I *really* don't want).  
>>So, does anyone have a pattern which allows setting an attribute on a 
>>class which doesn't go through the setattr machinery (i.e. can be used 
>>within a descriptor)? 
>>    
>>
>
>Maybe you could create just new attribute.  Call it _shadow, perhaps. 
>Then the setter does setattr(client._shadow, name, value).  The shadow
>could be a plain class like:
>
>class Shadow(object): pass
>
I'm doing the rough equivalent with a dictionary, was really looking for 
something more elegant, in particular, something that would make use of 
the already-existing class' dictionary, rather than creating a new one.
...

>May or may not be more elegant, but you can decide for yourself.
>  
>
Basically the same, still want more elegance :) ,
Mike

_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/








More information about the Python-list mailing list