> On 20 Jul 2020, at 09:56, Alex Hall <alex.moj...@gmail.com> wrote:
> 
> On Mon, Jul 20, 2020 at 10:36 AM Rob Cliffe via Python-ideas 
> <python-ideas@python.org <mailto:python-ideas@python.org>> wrote:
> May I repeat:  Spelling 'if break:' and 'if not break:' rather than say 
> 'on_break:' etc. would avoid adding new keywords.
> 
> I don't know what to do about the zero iterations case, though.
> 
> It could be that if `break` appears somewhere that an expression is expected, 
> it becomes an expression with the value 0 or 1 (or False or True) to indicate 
> the number of breaks that happened in the previous loop, and similarly some 
> other bit of code involving keywords can become the number of iterations of 
> the previous loop. This could be represented by `for`, `len(for)`, `pass`, 
> etc. So one might write:
> 
> ```
> for x in ...:
>     ...
> if not pass:
>     ...
> elif pass == 1:
>     ...
> else:
>     ...
> ```

To avoid the ambiguity of if after for why not follow for with elif?

for x in ...:
        ...

elif break:
        # break was called
elif not break:
        # looped at least once and break not used
elif pass:
        # same as else today
        # loop'ed no times

(I always have to think what else means after a for).


Barry


> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/N65ZZJPLN6LBPQOURDKJNXWGT64T3ZZK/
> Code of Conduct: http://python.org/psf/codeofconduct/

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QBT52KIMFB53HEPQV4CBUN7NPHUZEFL4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to