On Wed, Nov 14, 2007 at 04:43:28AM -0800, ted b wrote: > 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!
I think you want to update an instance of a class, not the class itself. If you do: class Two: def __init__(self): self.value = 1 def update(self): self.value = 9 class One: def __init__(self): self.value = 3 instance_of_Two = Two() def getTwo(self): print "testTwo's value", instance_of_Two().value instance_of_Two.update() print "testTwo's updated value", instance_of_Two().value HTH Yoram -- Yoram Hekma Unix Systems Administrator CICT Department AOES Netherlands B.V. Haagse Schouwweg 6G 2332 KG Leiden, The Netherlands Phone: +31 (0)71 5795588 Fax: +31 (0)71 5721277 e-mail: [EMAIL PROTECTED] http://www.aoes.com
signature.asc
Description: Digital signature
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor