[Python-Dev] List copy and clear (was Re: Inconsistent API for sets.Set and build-in set) (original) (raw)

Nicolas Fleury nidoizo at yahoo.com
Fri Jul 1 22:04:58 CEST 2005


Raymond Hettinger wrote:

Several thoughts:

As I told you in a private dicussion, you have convinced me about copy. About clear, however, I feel I have to defend my colleagues and myself, who almost all wasted time once (but only once) searching how to clear a list. Improving the docs (like adding an additional example in the table at http://www.python.org/doc/2.4.1/lib/typesseq-mutable.html) would be good. To me, "del mylist[:]" and "mylist[:] = []" are not "how to clear a list" but "how to clear list using slicing". That's why I think it's counter-intuitive, since you end up using slicing in a situation that has nothing to do with slicing.

We agree there's no need about generic clearing. It's only about consistency and ease of learning/self-documentation. So let's look at the reasons to not do it:

Overall, I think the addition of clear would be an improvement to the language, particularly in the autocompletion world of ours;)

Regards, Nicolas



More information about the Python-Dev mailing list