trevor lock wrote:
> Hello,
>
> I've just started using python and have observed the following :
>
> class foo:
> a=[]
> def __init__(self, val):
> self.a.append ( val )
> def getA(self):
> print self.a
> return self.a
>
> z = foo(5)
> y = foo(4)
>
At Wednesday 25/10/2006 16:19, trevor lock wrote:
I've just started using python and have observed the following :
class foo:
a=[]
def __init__(self, val):
self.a.append ( val )
It's a common pitfall. As seen just a few days ago:
http://groups.google.com/group/comp.lang.py
trevor lock wrote:
> Hello,
>
> I've just started using python and have observed the following :
>
> class foo:
> a=[]
> def __init__(self, val):
> self.a.append ( val )
> def getA(self):
> print self.a
> return self.a
>
> z = foo(5)
> y = foo(4)
> z.
Hello,I've just started using python and have observed the following :class foo: a=[] def __init__(self, val): self.a.append ( val ) def getA(self): print self.a return self.az = foo(5)y = foo(4)z.getA()>> [5, 4]I was expecting that everytime I created an i