Multi-dimensional list initialization

Chris Angelico rosuav at gmail.com
Tue Nov 6 07:07:06 CET 2012


On Tue, Nov 6, 2012 at 4:51 PM, Andrew Robinson
<andrew3 at r3dsolutions.com> wrote:
> I really don't think doing a shallow copy of lists would break anyone's
> program.

Well, it's a change, a semantic change. It's almost certainly going to
break _something_. But for the sake of argument, we can suppose that
the change could be made. Would it be the right thing to do?

Shallow copying by default would result in extremely weird behaviour.
All the same confusion would result, only instead of comparing
[None]*4 with [[None]]*4, there'd be confusion over the difference
between [[None]]*4 and [[[None]]]*4.

I don't think it would help anything, and it'd result in a lot more
work for no benefit.

ChrisA


More information about the Python-list mailing list