list.clear() missing?!?

Fredrik Lundh fredrik at pythonware.com
Tue Apr 11 11:08:46 EDT 2006


Ville Vainio wrote:

> I tried to clear a list today (which I do rather rarely, considering
> that just doing l = [] works most of the time) and was shocked, SHOCKED
> to notice that there is no clear() method. Dicts have it, sets have it,
> why do lists have to be second class citizens?

because Python already has a perfectly valid way to clear a list,
perhaps ?

    del l[:]

(lists are not mappings, so the duck typing argument don't really
apply here.)

</F>






More information about the Python-list mailing list