replacing `else` with `then` in `for` and `try`

Jon Ribbens jon+usenet at unequivocal.eu
Fri Nov 3 07:28:11 EDT 2017


On 2017-11-03, Alexey Muranov <alexey.muranov at gmail.com> wrote:
> 'Then' describes what happens next indeed, unless some extraordinary 
> situation prevents it from happening, for example:
>
>     try:
>         go_to_the_bakery()
>     then:
>         buy_croissants(2)
>     except BakeryClosed:
>         go_to_the_grociery()
>         buy_baguette(1)
>     finally:
>         come_back()
>
> I know this is a poor program example (why not to use a boolean return 
> value instead of an exception, etc.), and i know that currently in 
> Python `except` must precede `else`, it is just to illustrate the 
> choice of terms.

It looks like you're suggesting not just changing the 'else' keyword
to 'then', but changing the syntax completely. The above is certainly
not an improvement on the status quo, as it is completely
counter-intuitive that exceptions in the 'then' clause will not be
caught by the 'except' clauses.



More information about the Python-list mailing list