Static data

Static data (or class variables) are common to all instances
>>> class Point:
	counter = 0 # static variable, counts no of instances
	def __init__(self, x, y):
		self.x = x;  self.y = y;  
                Point.counter += 1
		
>>> for i in range(1000):
	p = Point(i*0.01, i*0.001)
	
>>> Point.counter     # access without instance
1000
>>> p.counter         # access through instance
1000

previousnexttable of contents