Why property works only for objects?
Shalabh Chaturvedi
shalabh at cafepy.com
Sat Mar 11 16:56:21 EST 2006
Michal Kwiatkowski wrote:
> Alex Martelli napisaĆ(a):
>>>>> obj.__dict__
>> {}
>>
>> ...the presence of '__dict__' as an entry in C is confusing the issue,
>> because that's what you get in this case as obj.__dict__.
>
> It still bugs me. What's the actual procedure when doing attribute
> assignment? I understand it like this:
>
> obj.attr = value
> * if instance class has __setattr__, call it
> * else: if class has an attribute with name "attr" check if it's a
> descriptor; when it's overriding descriptor, call its __set__
> method, otherwise raise AttributeError
> * else: bind "attr" as object attribute
>
Here is a step-by-step description of what happens when you set or get
an attribute on an object:
http://cafepy.com/article/python_attributes_and_methods/ch01s05.html
Cheers,
Shalabh
More information about the Python-list
mailing list