[Python-ideas] Control Flow - Never Executed Loop Body

Thomas Güttler guettliml at thomas-guettler.de
Wed Apr 6 10:16:49 EDT 2016



Am 24.03.2016 um 18:44 schrieb Sven R. Kunze:
> On 24.03.2016 14:54, Thomas Güttler wrote:
>> for item in my_iterator:
>>     # do per item
>> on empty:
>>    # this code gets executed if iterator was empty
>> on break:
>>    # this code gets executed if the iteration was left by a "break"
>> on notempty:
>>    # ...
>>
>
> Hmm, interesting. "on" would indeed be a distinguishing keyword to "except". So, "except" handles exceptions and "on"
> handles internal control flow (the iter protocol). Nice idea actually.

I thank you, because you had the idea to extend the loop syntax :-)

But I guess it is impossible to get "on empty" implemented.


Regards,
   Thomas Güttler

-- 
Thomas Guettler http://www.thomas-guettler.de/


More information about the Python-ideas mailing list