Re: Why property works only for objects?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Why property works only for objects?

From: Shalabh Chaturvedi <shalabh@cafepy.com>
Date: Sat Mar 11 2006 - 22:56:21 CET

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
Received on Sun Apr 30 11:36:06 2006