'while' in list comprehension?
Hung Jung Lu
hungjunglu at yahoo.com
Wed Oct 22 21:18:46 EDT 2003
jsaul <jsaul at gmx.de> wrote in message news:<20031022175924.GA10716 at jsaul.de>...
>
> foo = [ i for i in bar while len(i)>0 ]
>
> Is there any reason for not having this kind of thing? I actually
> miss it pretty often.
Could you provide an example where you need it?
>From your message, it seems "bar" might be a list of strings. If so, you could use:
foo = bar[:bar.index('')]
regards,
Hung Jung
More information about the Python-list
mailing list