Georg Brandl added the comment:

There is no interning going on.  Multiplying lists just copies references.

This is not so surprising if you consider that the case may be simple for 
nested lists, but what about ``[a] * 3`` with some arbitrary object "a"?  
Copying (or even deep copying) that object is usually not wanted, and 
impossible in general.

This is also documented here (see especially note 2 below the table):
https://docs.python.org/2/library/stdtypes.html#sequence-types-str-unicode-list-tuple-bytearray-buffer-xrange

You're right though that this might be good to mention in the tutorial, as it 
comes up every now and then.  I'll leave the issue open to discuss that.

----------
nosy: +georg.brandl

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

Reply via email to