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

kj at
Fri Nov 13 22:26:01 CET 2009

...just bit me in the "fuzzy posterior".  The best I can come up with
is the hideous

  lol = [[] for _ in xrange(500)]

Is there something better?  What did one do before comprehensions
were available?  I suppose in that case one would have to go all
the way with

  lol = [None] * 500
  for i in xrange(len(lol)):
      lol[i] = []

Yikes.  10 miles uphill, both ways...


More information about the Python-list mailing list