[Python-ideas] Yield-from example: A parser

Bruce Frederiksen dangyogi at gmail.com
Wed Feb 18 17:45:33 CET 2009

Greg Ewing wrote:
> Antoine Pitrou wrote:
>> (*) by the way, using a "for" loop would probably have felt more natural
> Not sure what you mean by that. There's no single place
> in the parser that loops until the input is exhausted.
I guess I'm not the only one who's intuitive feel for "for" loops is 
that they run to exhaustion (and, yes, it feels right to use for loops 
to search a list for something and break when it's found, but even then 
it feels like the program should be done with the iterable when the for 
loop terminates).

So it's interesting that the for statement is instinctively avoided in 
this situation when it doesn't need to be (as it's currently defined).

But this could also be seen as a counter-example to my proposal for a 
new-style for statement (if it had been written with a for statement :-).

-bruce frederiksen

More information about the Python-ideas mailing list