Re: Class properties and object properties

2008-10-06 Thread SuperZE
TYVM Diez and Jerry Now I understand how this works -- http://mail.python.org/mailman/listinfo/python-list

Re: Class properties and object properties

2008-10-06 Thread SuperZE
> Because you declare myList to be a *class*-level variable, which means *all* > instances of that class (a and b in your case) *share* it. Python does not > declare *instance* variables the way you do. > > Instead, do this: > > class Foo(object): >     def __init__(self): >         self.myList = [

Class properties and object properties

2008-10-06 Thread SuperZE
Learning python I was rewriting some of my old programs to see the pros and cons of python when a steped in some weird (at least for me) behavior. Here it is simplified The code: >>> class Test1: myList = [4 for n in range(4)] myInt = 4 >>> a = Test1() >>> b = Test1() >>> a.myLis