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

Brian J Mingus Brian.Mingus at Colorado.EDU
Sat Nov 14 05:08:46 EST 2009


On Sat, Nov 14, 2009 at 2:50 AM, Vlastimil Brom <vlastimil.brom at gmail.com>wrote:

> 2009/11/14 Brian J Mingus <Brian.Mingus at colorado.edu>:
> >
> >
> > On Sat, Nov 14, 2009 at 1:50 AM, Paul Rubin <http://phr.cx
> @nospam.invalid>
> > wrote:
> >>
> >> kj <no.email at 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
> --
>

I see.. Here's what I came up with: list(eval('[],'*500))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091114/8b3b5a07/attachment.html>


More information about the Python-list mailing list