Question about accessing class-attributes.

Nikolai Kirsebom nikolai.kirsebom.NOJUNK at siemens.no
Thu Apr 24 07:29:44 EDT 2003


Given the following class hierarchy:
	
class A(object):
	InstCount = 0
	def __init__(self):
		self.__class__.__dict__['InstCount'] += 1

class B(A):
	InstCount = 0

class C(A):
	InstCount = 0

Is the syntax used for incrementing the class-attribute for every
instanciation 'the way' it should be done ?

Nikolai Kirsebom







More information about the Python-list mailing list