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 sandro.tosi
Recipients sandro.tosi, xintx-ua
Date 2011-07-20.17:07:09
SpamBayes Score 0.008126954
Marked as misclassified No
Message-id <1311181630.55.0.746547682604.issue12597@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,
no it's not a bug :)

What you actually get with [[0]]*3 is a list of 3 references to the same list, [0]:

>>> a = [[0], [0], [0]]
>>> b = [[0]]*3
>>> for i in a: print(id(i))
... 
139807725184032
139807725300280
139807725300520
>>> for i in b: print(id(i))
... 
139807725324016
139807725324016
139807725324016
History
Date User Action Args
2011-07-20 17:07:10sandro.tosisetrecipients: + sandro.tosi, xintx-ua
2011-07-20 17:07:10sandro.tosisetmessageid: <1311181630.55.0.746547682604.issue12597@psf.upfronthosting.co.za>
2011-07-20 17:07:09sandro.tosilinkissue12597 messages
2011-07-20 17:07:09sandro.tosicreate