Unclear On Class Variables

Tim Daneliuk tundra at tundraware.com
Thu Jan 13 07:18:26 EST 2005


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 ...
-- 
----------------------------------------------------------------------------
Tim Daneliuk     tundra at tundraware.com
PGP Key:         http://www.tundraware.com/PGP/



More information about the Python-list mailing list