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

2009-11-16 Thread kj
In <6e20a31b-2218-49c5-a32c-5f0147db3...@k19g2000yqc.googlegroups.com> Jon Clements writes: lol =3D map(lambda L: [], xrange(5)) [id(i) for i in lol] >[167614956, 167605004, 167738060, 167737996, 167613036] Oh yeah, map! I'd forgotten all about it. Thanks! kynn -- http://mail.pyth

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

2009-11-14 Thread Steven D'Aprano
On Fri, 13 Nov 2009 21:26:01 +, kj wrote: > ...just bit me in the "fuzzy posterior". It's not a bug. Just because it doesn't behave as you would like it to behave doesn't mean it isn't behaving as designed. > The best I can come up with is the hideous > > lol = [[] for _ in xrange(500)

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

2009-11-14 Thread Paul Rubin
Ulrich Eckhardt writes: > That said, [[]]*500 is IMHO more readable. But the issue in the thread is that it does the wrong thing. -- http://mail.python.org/mailman/listinfo/python-list

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

2009-11-14 Thread Ulrich Eckhardt
Diez B. Roggisch wrote: > kj schrieb: >> lol = [[] for _ in xrange(500)] > > If you call that hideous, I suggest you perform the same exercise in > Java or C++ - and then come back to python and relax I might be missing something that's not explicitly mentioned here, but I'd say that all n

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

2009-11-14 Thread Brian J Mingus
On Sat, Nov 14, 2009 at 2:50 AM, Vlastimil Brom wrote: > 2009/11/14 Brian J Mingus : > > > > > > On Sat, Nov 14, 2009 at 1:50 AM, Paul Rubin @nospam.invalid> > > wrote: > >> > >> kj writes: > >> > lol = [None] * 500 > >> > for i in xrange(len(lol)): > >> > lol[i] = [] >

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

2009-11-14 Thread Vlastimil Brom
2009/11/14 Brian J Mingus : > > > On Sat, Nov 14, 2009 at 1:50 AM, Paul Rubin > wrote: >> >> kj writes: >> >   lol = [None] * 500 >> >   for i in xrange(len(lol)): >> >       lol[i] = [] >> >> lol = map(list, [()] * 500) > > Could someone explain what the deal is wit

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

2009-11-14 Thread Brian J Mingus
On Sat, Nov 14, 2009 at 1:50 AM, Paul Rubin wrote: > kj 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 -- http://mai

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

2009-11-14 Thread Paul Rubin
kj writes: > lol = [None] * 500 > for i in xrange(len(lol)): > lol[i] = [] lol = map(list, [()] * 500) -- http://mail.python.org/mailman/listinfo/python-list

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

2009-11-14 Thread Diez B. Roggisch
kj schrieb: ...just bit me in the "fuzzy posterior". The best I can come up with is the hideous lol = [[] for _ in xrange(500)] If you call that hideous, I suggest you perform the same exercise in Java or C++ - and then come back to python and relax Diez -- http://mail.python.org/ma

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

2009-11-13 Thread Jon Clements
On 13 Nov, 21:26, kj wrote: > ...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?   That's generally the accepted way of creating a LOL. > What did one do before comprehensions > were availabl