StopIteration in the if clause of a generator expression

Steven Bethard steven.bethard at gmail.com
Sun Apr 3 18:09:42 EDT 2005


Raymond Hettinger wrote:
> [Peter Otten]
> 
>>Do you see any chance that list comprehensions will be redefined as an
>>alternative spelling for list(<generator expression>)?
> 
> Not likely.  It is possible that the latter spelling would make it possible for
> Py3.0. eliminate list comps entirely.  However, they are very popular and
> practical, so my bet is that they will live on.

I suspect you're right, but I certainly wouldn't complain if list comps 
disappeared. TOOWTDI and all, and I often find myself alternating 
between the two when I can't decide which one seems more Pythonic. 
(These days I generally write a listcomp, but I wouldn't put any money 
on my code being entirely consistent about this...)

STeVe



More information about the Python-list mailing list