Ezio Melotti <ezio.melo...@gmail.com> added the comment:

>>> a = ['1']
>>> b = []
>>> c = a
# now c and a refer to the same object
>>> b.append(a)
# this object is appended to b
>>> a
['1']
>>> b
[['1']]
>>> c
['1']
# a and c refer to the same object you have in b
# so all these ['1'] are actually the same object
>>> a = ['2']
# now a refers to another object
>>> c.extend(a)
# and here you are extending the object referred by c
# and the same object that you have in b
>>> b
[['1', '2']]
>>> c
['1', '2']
# so this is correct
>>> a
['2']
>>>

You can use id() to verify the identity of the objects, and read 
http://python.net/crew/mwh/hacks/objectthink.html for more information.

----------
nosy: +ezio.melotti
stage:  -> committed/rejected

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14707>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to