From: Vlastimil Brom on
2009/11/14 Brian J Mingus <Brian.Mingus(a)colorado.edu>:
>
>
> On Sat, Nov 14, 2009 at 1:50 AM, Paul Rubin <http://phr.cx(a)nospam.invalid>
> wrote:
>>
>> kj <no.email(a)please.post> writes:
>> >   lol = [None] * 500
>> >   for i in xrange(len(lol)):
>> >       lol[i] = []
>>
>> lol = map(list, [()] * 500)
>
> Could someone explain what the deal is with this thread? Thanks.
> [[]]*500
>

Try
>>> lst=[[]]*500
>>> lst[7].append(2)
>>> lst
to see...

vbr
From: Ulrich Eckhardt on
Diez B. Roggisch wrote:
> kj schrieb:
>> lol = [[] for _ in xrange(500)]
>
> If you call that hideous, I suggest you perform the same exercise in
> Java or C++ - and then come back to python and relax....

I might be missing something that's not explicitly mentioned here, but I'd
say that all non-associative containers in C++ have a resize() method, some
even taking an initial size in their constructor.

That said, [[]]*500 is IMHO more readable.

Uli

From: Paul Rubin on
Ulrich Eckhardt <doomster(a)knuut.de> writes:
> That said, [[]]*500 is IMHO more readable.

But the issue in the thread is that it does the wrong thing.