Georg Brandl added the comment: I'm sorry, this is no bug. List multiplication works by referencing, there is no way to implement it differently in a straightforward way.
Note that in >>> [a[:]] + [a[:]] the expression "a[:]" is evaluated twice, yielding two independent copies of a. In contrast, >>> [a[:]] * 2 evaluates "a[:]" only once, before the list multiplication is done. Because of the same reason, >>> [deepcopy(a)] * 2 doesn't work as you want. One way to do what you have in mind is >>> [a[:] for i in range(2)] which evaluates the "a[:]" once for each iteration of the list comprehension loop. ---------- nosy: +georg.brandl resolution: -> invalid status: open -> closed __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1408> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com