vars between classes

Marc Tardif intmktg at CAM.ORG
Sat May 27 10:53:41 EDT 2000


OK, here's working code now. My previous code was only meant to help
demonstrate my problem. In this new code, I have tried to change var in
the first class by calling "first" explicitly. Unfortunately, "3" is still
not printed:

#!/usr/local/bin/python

class first:
  def __init__(self, var):
    self.var = var
    self.myMethod()

  def myMethod(self):
    print "first:", self.var
    second(self.var)
    print "last:", self.var

class second(first):
  def myMethod(self):
    print "second:", self.var
    first.var = 3

def test(var):
  first(var)

if (__name__=='__main__'):
  test(2)






More information about the Python-list mailing list