StopIteration in the if clause of a generator expression

Raymond Hettinger vze4rx4y at verizon.net
Mon Apr 4 15:44:10 EDT 2005


[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.


Raymond Hettinger





More information about the Python-list mailing list