[Python-ideas] clear() method for lists

George Sakkis george.sakkis at gmail.com
Fri Apr 3 20:54:57 CEST 2009


On Fri, Apr 3, 2009 at 6:53 AM, Andre Roberge <andre.roberge at gmail.com> wrote:

> Hi everyone,
>
> On the general Python list, a suggestion was made to add a clear() method to
> list, as the "obvious" way to do
> del some_list[:]
> or
> some_list[:] = []
>
> since the clear() method is currently the obvious way to remove all elements
> from dict and set objects.
>
> I believe that this would be a lot more intuitive to beginners learning the
> language, making Python more uniform.

It's obviously more explicit, but at the same it's a rather infrequent
operation and the current ways are not particularly ugly. +0, no
strong feelings either way.

George



More information about the Python-ideas mailing list