a class variable question
Marco Wahl
marco.wahl at gmail.com
Wed Jun 28 02:17:34 EDT 2006
Hi,
just some lines added below. hth
micklee74 at hotmail.com wrote:
> hi
> i have define a class like this
>
> class A:
> _var1 = 0
> def __init__(self):
> ## some initialization
> self.func1()
>
> def func1():
self
> .....
> _var1 = 1
A._var1 = 1
> ....
>
> def getvarValue(self):
> return _var1
return A._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