a class variable question
Erik Max Francis
max at alcyone.com
Wed Jun 28 02:22:41 EDT 2006
Pierre Quentel wrote:
> In func1, _var1 = 1 creates a local variable _var1 (local to the
> method), not an attribute of the instance. If you want an instance
> attribute you must specify the reference to the instance by
> self._var1 = 1 ; self must be passed as an attribute to func1
>
> def func1(self):
> self._var1 = 1
Note this only changes the attribute in the instance. If he wants it to
be changed for all other instances, he needs to change it in the class
with:: A._var1 = 1
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
Every path has its puddle.
-- (an English proverb)
More information about the Python-list
mailing list