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: - It's only useful for new Python programmers (I mean first-time clearers), once you know it, you know it. - That would be a third way to clear a list. However, I don't like this argument in this specific case, because IMO the current ways are just slicing capabilities, as "<< 1" and "* 2" can be the same on a int. - All APIs trying to emulate a list would end up incomplete. I have difficulty judging that one. A method addition doesn't sound so bad to me. If it is the showstopper, maybe a Python 3000 thing? Overall, I think the addition of clear would be an improvement to the language, particularly in the autocompletion world of ours;) Regards, Nicolas _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com