Warning when new attributes are added to classes at run time

Matthew Wilson matt at overlook.homelinux.net
Thu Jul 20 09:47:06 EDT 2006


On Thu 20 Jul 2006 04:32:28 AM EDT, Bruno Desthuilliers wrote:
>>             self.__dict__[name] = value
> Make it:	
>               object.__setattr__(self, name, value)
>
> Your approach will lead to strange results if you mix it with properties
> or other descriptors...

Thanks!

>>     class C1(C):
>> 
>>         standard_attributes = ['a1', 'a2']
>
> DRY violation here. And a potential problem with inheritance (as always
> with class attributes).

Considering I had to look up what DRY meant before replying to this
message, I may be missing your point.  Is the repeat here that each
subclass has to define its own list of standard attributes?   Or, is it
that the standard_attributes list holds strings, but I could build that
list up by looking at my existing attributes?

If you're feeling charitable, can you explain what you mean a little
more?

TIA


-- 
A better way of running series of SAS programs:
http://overlook.homelinux.net/wilsonwiki/SasAndMakefiles



More information about the Python-list mailing list