[Python-ideas] clear() method for lists

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

Nick Coghlan wrote:

> I believe it runs afoul of the moratorium, but a getitem() builtin might
> be a better idea (since it would then work for any class that implements
> __getitem__).

Not quite the same way, though. The dict get() method knows
about the internals of the object, so it can work very
efficiently and without danger of masking bugs by catching
the wrong exception. A generic getitem() wouldn't be able
to do that.


More information about the Python-ideas mailing list