[Python-ideas] for-while statement

Rob Cliffe rob.cliffe at btinternet.com
Wed Feb 19 15:46:12 CET 2014


On 19/02/2014 13:34, Alejandro López Correa wrote:
> Hello,
>
> I think adding an optional "WHILE" clause in "FOR" loops might be
> useful sometimes (shorter code and/or improved readability):
>
> for #VAR# in #SEQUENCE# while #WATCHDOG_EXPRESSION#:
>    #CODE_BLOCK#
It seems to me this would be the same as

for #VAR# in #SEQUENCE#:
   if not (#WATCHDOG_EXPRESSION#): break
   #CODE_BLOCK#


which doesn't really seem to me to justify adding new syntax.
Rob Cliffe




More information about the Python-ideas mailing list