while true: !!!

Andrew Henshaw andrew_dot_henshaw_at_earthling_dot_net
Wed Dec 20 22:44:45 EST 2000


"Tim Peters" <tim.one at home.com> wrote in message
news:mailman.977339546.988.python-list at python.org...
> [gbreed at cix.compulink.co.uk]
> > ...
> > If you want to empty a sequence, but preserve the type, try
> > filter(lambda x:0, asequence).
>
> Picking a nit:  that returns an empty list, regardless of type(asequence).
> To get an empty sequence of the same type, do
>
>     asequence[:0]
>
> or even
>
>     asequence * 0
>
> there's-only-one-way-to-do-it-ly y'rs  - tim
>
>
Yes, that's the way that I was thinking the (arguably logical) change in
"not sequence" semantics might be used.  I don't propose that such a change
be made, however.

Andrew Henshaw





More information about the Python-list mailing list