I hate gmail, always forgetting to set the right recipient...
---------- Forwarded message ----------
From: Martin Marcher <ma****@marcher.name>
Date: 29.10.2007 10:11
Subject: Re: sharing vars with different functions
To: "sc********@gmail.com" <sc********@gmail.com>
2007/10/29,
sc********@gmail.com <sc********@gmail.com>:
Im tryin to call a var thats sitting in a function, example:
i guess im not graspng the whole global or local var topic..
does this help?
>>class Foo(object):
.... somevar = ["a", "b"]
.... def __init__(self):
.... self.another_var = ["c", "d"]
....
>>Foo.somevar
['a', 'b']
>>f = Foo()
f.somevar
['a', 'b']
>>f.another_var
['c', 'd']
>>Foo.somevar = "New Value"
f.somevar
'New Value'
>>Foo.another_var
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'Foo' has no attribute 'another_var'
--
http://noneisyours.marcher.name http://feeds.feedburner.com/NoneIsYours
--
http://noneisyours.marcher.name http://feeds.feedburner.com/NoneIsYours