The ol' [[]] * 500 bug...

Ulrich Eckhardt doomster at knuut.de
Sat Nov 14 10:13:08 EST 2009


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




More information about the Python-list mailing list