different binding behavior

Gabriel Zachmann zach at in.tu-clausthal.de
Thu Nov 10 16:43:53 EST 2005


It seems to me that the following behavior of python (2.4.1) is inconsistent:

 >>> a=1
 >>> b=a
 >>> a+=1
 >>> b
1
 >>> a
2
 >>> a=[1,2]
 >>> b=a
 >>> b+=[3]
 >>> a
[1, 2, 3]
 >>> b
[1, 2, 3]

Why was it implemented like this??

Best regards,
Gabriel.

-- 
/-----------------------------------------------------------------------\
| Any intelligent fool can make things bigger, more complex,            |
| or more violent. It takes a touch of genius - and a lot of courage -  |
| to move in the opposite direction.                         (Einstein) |
\-----------------------------------------------------------------------/



More information about the Python-list mailing list