Overwriting property-> can't set attribute

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Tue Aug 26 06:33:19 EDT 2008


norseman a écrit :
> Gregor Horvath wrote:
>> Hi,
>>
>> why is this code failing?
>>
>> class B(object):
>>     pass
>>
>> B.testattr = property(lambda s:"hallo")
>> b = B()
>> b.testattr = "test"
>>
>>
>> Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
>>
>> /tmp/python-14202ViU.py in <module>()
>>      14 B.testattr = property(lambda s:"hallo")
>>      15 b = B()
>> ---> 16 b.testattr = "test"
>>      17
>>      18
>>
>> <type 'exceptions.AttributeError'>: can't set attribute
>>
>> -- 
>> Greg
>> -- 
>> http://mail.python.org/mailman/listinfo/python-list
>>
> ====================================
> 
> b = B()       # synonyms

Not exactly, no. You probably missed the call operator applied to B.

(snip erroneous explanation).



More information about the Python-list mailing list