Pop a list from beginning ? and memory saving...
peter at engcorp.com
Wed Jun 5 10:40:34 EDT 2002
Jeff Epler wrote:
> On Tue, Jun 04, 2002 at 11:36:39PM -0400, Peter Hansen wrote:
> (speaking about this expression):
> >> l[:] = 
> > Oh, and in my opinion, that is obscure and deserves a
> > comment explaining how it works, and why it is being done.
> > I might not feel that way if I write that idiom a few times,
> > though. :)
> del l[:]
> is clearer than
> l[:] = 
> I'd accept the first one immediately, and puzzle over the second one for
> a short (or even long) time.
Agreed, although my brain knows that "x = l[:]" is the idiom
for making a copy of a list, so it wants to tell me that "del l[:]"
is just going to make a copy, then delete it right away.
More information about the Python-list