[Python-Dev] PEP 3142: Add a "while" clause to generator expressions

Nick Coghlan ncoghlan at gmail.com
Tue Jan 20 21:42:36 CET 2009


Gerald Britton wrote:
> I wonder if this is a bug?

Nope, it's part of the defined behaviour. Avoiding the overhead of the
GE machinery is actually the main advantage in using a comprehension
over the equivalent generator expression. Deliberately raising
StopIteration is about the only way to notice the small semantics
difference (in Py3k anyway - in 2.x there are scoping differences as well).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-Dev mailing list