vars between classes
Doug Stanfield
DOUGS at oceanic.com
Sat May 27 14:05:53 EDT 2000
Maybe what you really want to do is the following. It may be you're
confusing class construction and inheritance and the effects of
instantiation:
#!/usr/local/bin/python
class first:
class_var = 0
def __init__(self, var):
self.var = var
first.class_var = var
self.myMethod()
def myMethod(self):
print "first:", self.class_var
second(self.var)
print "last:", self.class_var
class second(first):
def myMethod(self):
print "second:", self.class_var
first.class_var = 3
def test(var):
first(var)
if (__name__=='__main__'):
test(2)
More information about the Python-list
mailing list