This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezio.melotti
Recipients Daniel543, ezio.melotti, loewis
Date 2012-05-02.16:25:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1335975936.61.0.646052668213.issue14707@psf.upfronthosting.co.za>
In-reply-to
Content
>>> 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.
History
Date User Action Args
2012-05-02 16:25:36ezio.melottisetrecipients: + ezio.melotti, loewis, Daniel543
2012-05-02 16:25:36ezio.melottisetmessageid: <1335975936.61.0.646052668213.issue14707@psf.upfronthosting.co.za>
2012-05-02 16:25:36ezio.melottilinkissue14707 messages
2012-05-02 16:25:35ezio.melotticreate