Global variables within classes.

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sat Nov 10 13:41:19 EST 2007


On Sat, 10 Nov 2007 17:39:04 +0000, Marc 'BlackJack' Rintsch wrote:

> On Sat, 10 Nov 2007 18:53:08 +0200, Donn Ingle wrote:
>>>> print b.ref.attribute # print "haschanged"
>>>> 
>>>> print j.ref.attribute #prints "original value"
>>>> ## If it changed and an attribute of the Class, then
>>>> ## why is it back to "original value" ?
>>> 
>>> Because the *instance* of `Test` bound to `j.ref` does not have
>>> `attribute` it is looked up in the *class* `Test`.
>> Okay, I sort of see that. It's not a property of 'j' so it looks upwards
>> into the class.
> 
> Its not an attribute of `j.ref`!

Oops, this should read:  It's not an attribute of `j`, but `j.ref`.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list