StopIteration in the if clause of a generator expression
Steven Bethard
steven.bethard at gmail.com
Mon Apr 4 17:13:47 EDT 2005
Raymond Hettinger wrote:
> [Steven Bethard]
>
>>and I often find myself alternating
>>between the two when I can't decide which one seems more Pythonic.
>
> Both are pythonic.
>
> Use a genexp when you need a generator
> and use a listcomp when you need a list.
So do I read this right in preferring
[<x> for <y> in <z>]
over
list(<x> for <y> in <z>)
?
STeVe
More information about the Python-list
mailing list