list.clear() missing?!?

Mel Wilson mwilson-to at sympatico.ca
Wed Apr 12 14:28:49 EDT 2006


Ville Vainio wrote:
> Fredrik Lundh wrote:
>>because Python already has a perfectly valid way to clear a list,
>>perhaps ?
>>
>>    del l[:]
> 
> 
> Ok. That's pretty non-obvious but now that I've seen it I'll probably
> remember it. I did a stupid "while l: l.pop()" loop myself.

Actually, it's in the Library Reference (that we keep under 
our pillows) section 2.3.6.4 Mutable Sequence Types.

         Cheers,        Mel.



More information about the Python-list mailing list