[Tutor] class accessing another's updated property

ted b phpmoonlighter at yahoo.com
Wed Nov 14 13:43:28 CET 2007


I want class One to be able to access access class
Two's value property after its been updated. Everytime
I try (by running, say testTwo().value) I get the
__init__ value. The update method fro class Two is
called elsewhere in the program, and I want class
One's "getTwo" method to access class Two's updated
value and give me '9' but i get '1'

Here's the code:

class One:
   def __init__(self):
      self.value = 3
   def getTwo(self):
      print "testTwo's updated value", Two().value

class Two:
   def __init__(self):
      self.value = 1
   def update(self):
      self.value = 9

Thanks in advance!


      ____________________________________________________________________________________
Be a better sports nut!  Let your teams follow you 
with Yahoo Mobile. Try it now.  http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ


More information about the Tutor mailing list