[ [ [] * y for y in range(3) ] * x for x in range(2) ]
David Eppstein
eppstein at ics.uci.edu
Thu Jan 30 01:01:51 EST 2003
In article <2463d77d.0301292034.1fdc47bd at posting.google.com>,
marcel_achim at videotron.ca (Marcel) wrote:
> I'm trying to allocate nested lists up-front using the subject line,
> instead of generating :
> [ [ [], [], [] ], [ [], [], [] ] ]
> I end up with :
> [ [], [ [], [], [] ] ]
What's wrong with [[[]]*3]*2 ?
--
David Eppstein UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/
More information about the Python-list
mailing list