[Python-ideas] clear() method for lists

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Feb 12 23:33:33 CET 2010


Masklinn wrote:

> Though I'm not sure it's a very good idea for lists. Semantically, lists
 > are to be iterated, not really to be indexed.

I don't think I agree that lists are meant primarily for
iteration. Indexing them is a perfectly legitimate and
useful thing to do.

However, I would agree that a list.get() operation with a
default seems to be a rather rare requirement. Usually
when you index a list, the index is generated by some
algorithm that guarantees it's within range.

I can't remember ever wanting a list.get() myself, and
if I ever did, I would be quite happy to write my own.

-- 
Greg



More information about the Python-ideas mailing list