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

kj no.email at please.post
Fri Nov 13 16:26:01 EST 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...

kynn



More information about the Python-list mailing list