'while' in list comprehension?

Emile van Sebille emile at fenx.com
Wed Oct 22 15:05:56 EDT 2003


jsaul asks...
> would then turn into
>
>     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.
>


How is this different from:

     foo = [ i for i in bar if len(i) ]

Emile van Sebille
emile at fenx.com






More information about the Python-list mailing list