a class variable question

micklee74 at hotmail.com micklee74 at hotmail.com
Wed Jun 28 02:06:08 EDT 2006


hi
i have define a class like this

class A:
         _var1 = 0
         def __init__(self):
                 ## some initialization
                 self.func1()

         def func1():
                  .....
                 _var1 = 1
                 ....

         def getvarValue(self):
                 return _var1
I wanted var1 to be "global" inside Class A.
when i do

AnInstance = A()
AnInstance.getvarValue()

it gives me 0. It should be 1.  What am i doing wrong here..thanks




More information about the Python-list mailing list