list.clear() missing?!?

Fredrik Lundh fredrik at pythonware.com
Thu Apr 13 03:11:31 EDT 2006


Peter Hansen wrote:

> It's not even clear that extend needs two lines:
>
>  >>> s = range(5)
>  >>> more = list('abc')
>  >>> s[:] = s + more
>  >>> s
> [0, 1, 2, 3, 4, 'a', 'b', 'c']
>
> Okay, it's not obvious, but I don't think s[:]=[] is really any more
> obvious as a way to clear the list.
>
> Clearly .extend() needs to be removed from the language as it is an
> unnecessary extension to the API using slicing

you just flunked the "what Python has to do to carry out a certain operation"
part of the "how Python works, intermediate level" certification.

</F>






More information about the Python-list mailing list