Variable Scope 2 -- Thanks for 1.

Francis Avila francisgavila at yahoo.com
Fri Jan 9 16:09:43 EST 2004


Jens Thiede wrote in message ...
>I found the querk in my code:
>
>a = [1, 2, 3];
>b = a;
>b.append(4);
>
>b == [1, 2, 3, 4]; # As it should.
>a == [1, 2, 3, 4]; # - Why?
>
>One would think that b is a referance to a - however I know it's not.

Ordinarily I would write a big custom-made explaination complete with
examples.  However:

http://starship.python.net/crew/mwh/hacks/objectthink.html

This is good enough.

--
Francis Avila




More information about the Python-list mailing list