Static vars in Python?
Hamish Lawson
hamish_lawson at yahoo.co.uk
Mon May 8 16:45:42 EDT 2000
It's actually quite simple to create and modify class variables:
class Thing:
count = 0
def __init__(self, value):
self.value = value
Thing.count = Thing.count + 1
a = Thing(14)
b = Thing(25)
c = Thing(32)
print b.value # Gives 25
print Thing.count # Gives 3
Hamish Lawson
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
More information about the Python-list
mailing list