Unclear On Class Variables

Diez B. Roggisch deetsNOSPAM at web.de
Thu Jan 13 07:36:36 EST 2005


Tim Daneliuk wrote:

> I am a bit confused.  I was under the impression that:
> 
> class foo(object):
> x = 0
> y = 1
> 
> means that x and y are variables shared by all instances of a class.
> But when I run this against two instances of foo, and set the values
> of x and y, they are indeed unique to the *instance* rather than the
> class.
> 
> It is late and I am probably missing the obvious.  Enlightenment
> appreciated ...

Without actual code how you set the vars, no one can answer that question.

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list