[Python-Dev] for...else

MRAB python at mrabarnett.plus.com
Wed Jul 26 20:46:23 EDT 2017


On 2017-07-27 01:07, Koos Zevenhoven wrote:
> On Jul 27, 2017 02:38, "MRAB" <python at mrabarnett.plus.com 
> <mailto:python at mrabarnett.plus.com>> wrote:
>
>     On 2017-07-26 23:55, Koos Zevenhoven wrote:
>
>
>         ​IMO,
>
>         for item in sequence:
>              # block
>         nobreak:   # or perhaps `if not break:`
>              # block
>
>         would be clearer (if the syntax is necessary at all).
>
>
>     You couldn't have "if not break:" because that would look like the
>     start of an 'if' statement.
>
>
> Do you mean as an implementation issue or for human readability?
>
I suppose you _could_ use "if not break:", but as 'if' normally 
indicates the start of an 'if' statement, you would get complaints about 
it! :-)

Maybe it would be clearer if it was "elif not break:". :-)

>     "nobreak" would introduce a new keyword, but "not break" wouldn't.
>
>
> Sure :)
>



More information about the Python-Dev mailing list