__set__ method is not called for class attribute access

Duncan Booth duncan.booth at invalid.invalid
Wed Aug 10 17:35:11 CEST 2011


Fuzzyman <fuzzyman at gmail.com> wrote:

>> The descriptor protocol only works when a value is being accessed or set
>> on an instance and there is no instance attribute of that name so the
>> value is fetched from the underlying class.
>>
> 
> That's not true. Properties, for example, can be got or set even when
> they shadow an instance attribute. You're (probably) thinking of
> __getattr__ which isn't invoked when an instance attribute exists.

Yes, Peter Otten already corrected me on that point last Friday and I 
posted thanking him on Sunday.


-- 
Duncan Booth http://kupuguy.blogspot.com



More information about the Python-list mailing list