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

Vlastimil Brom vlastimil.brom at gmail.com
Sat Nov 14 10:50:58 CET 2009


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



More information about the Python-list mailing list