On Mon, Oct 6, 2008 at 9:38 AM, SuperZE <[EMAIL PROTECTED]> wrote:
> Interesting, but that does not explain the difference in the behavior
> of myList and myInt
>
> Both were class-level variables, as far as I can see, and therefor a
> and b should also share it
They did share it, until you assigned an instance variable in b, which
shadowed the class variable. Example:
>>> class Test1:
myInt = 4
>>> a = Test1()
>>> b = Test1()
>>> a.myInt
4
>>> b.myInt
4
>>> Test1.myInt
4
>>> b.myInt = 3
>>> a.myInt
4
>>> b.myInt
3
>>> Test1.myInt
4
As soon as you bound the name b.myInt to a new value, it created an
instance variable. That hides the value of Test1.myInt.
--
Jerry
--
http://mail.python.org/mailman/listinfo/python-list