Best practice for object attributes?
bdesth at removethis.free.fr
Wed Apr 2 17:31:53 CEST 2003
Jp Calderone wrote:
> On Wed, Apr 02, 2003 at 04:12:36PM +0100, Michael Sparks wrote:
>>As far as I can tell the behaviour seems to be that you automatically
>>gain instance attributes that clone the state of the class attributes
>>at object creation time, which are then independent and can be modified
>>via the usual self.<attr> syntax later on. (They cannot however be
>>modified via the self.__dict__[<attr>] syntax since they're not stored
> Not quite. What really happens is simpler. When an attribute lookup on
> an instance fails, the lookup proceeds to the instance's class object (if it
> fails there, it proceeds to the class object's bases, and so on). The
> attributes aren't cloned, and the time of creation matters not.
Of course.... thought I had a brain, but it seems I can't find it today.
Someone seen my brain 'round here ?
More information about the Python-list