Question about idioms for clearing a list

Bryan Olson fakeaddress at nowhere.org
Tue Feb 7 16:17:24 EST 2006


Fredrik Lundh wrote:
> Steven D'Aprano wrote:
[...]
>>del L[:] works, but unless you are Dutch, it fails the
>>obviousness test.
> 
> 
> unless you read some documentation, that is.  del on sequences
> and mappings is a pretty fundamental part of Python.  so are slicings.

So is consistency; it ain't Perl, thank Guido.

Python now has, what, three built-in mutable collections types:
lists, dictionaries, and sets. Dicts and sets both have a clear()
method and lists do not. That's a wart, minor but easily fixed.


-- 
--Bryan



More information about the Python-list mailing list