Re: list.clear() missing?!?



Steven D'Aprano wrote:
On Tue, 11 Apr 2006 14:49:04 -0700, Ville Vainio wrote:

John Salerno wrote:

Thanks guys, your explanations are really helpful. I think what had me
confused at first was my understanding of what L[:] does on either side
of the assignment operator. On the left, it just chooses those elements
and edits them in place; on the right, it makes a copy of that list,
right? (Which I guess is still more or less *doing* the same thing, just
for different purposes)
Interestingly, if it was just a "clear" method nobody would be confused.

Even more importantly, you could say help(list.clear) and learn something
useful, instead of trying help(del) and getting a syntax error.
[snip more reasons to add list.clear()]

I think these are all good reasons for adding a clear method, but being that it has been so hotly contended in the past, I don't think it will get added without a PEP. Anyone out there willing to take out the best examples from this thread and turn it into a PEP?

STeVe
.



Relevant Pages

  • Re: list.clear() missing?!?
    ... John Salerno wrote: ... confused at first was my understanding of what Ldoes on either side ... of the assignment operator. ... if it was just a "clear" method nobody would be confused. ...
    (comp.lang.python)
  • Request for elucidation: enhanced generators
    ... I've read PEP 342 and the associated bit in ... aid the understanding too much. ... Ben Sizer ...
    (comp.lang.python)