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

Alexey Muranov alexey.muranov at gmail.com
Fri Nov 3 05:48:27 EDT 2017


On Thu, 2017-11-02 at 16:31 +0000, Jon Ribbens wrote:
> > On 2017-11-02, Steve D'Aprano <steve+python at pearwood.info> wrote:
>> > > On Fri, 3 Nov 2017 12:39 am, Jon Ribbens wrote:
>>> > > > Why would we want to make the language worse? It is fairly
>>> > > > obvious
>>> > > > what 'else' means,
>> > >
>> > > Yes, obvious and WRONG.
> >
> > Nope, obvious and right.
> >

I suppose that to continue this way we'd need at some point define 
somehow the meaning of "obvious."

> 
>>> > > > whereas 'then' has an obvious meaning that is in
>>> > > > fact the opposite of what it would actually do.
>> > >
>> > > Er... is today opposite day? Because 'then' describes precisely
>> > > what it
>> > > actually does.
> >
> > No, 'then' describes the opposite of what it does. The word 'then'
> > implies something that always happens next, whereas 'else' conveys
> > the correct meaning, which is something that happens if the course
> > of the preceding piece of code did not go as expected.
> >

Jon, i get from this that for you, when there is no exception in `try`, 
or no `break` in a loop, the things did not go as expected.  Either we 
need to agree that what is "expected" is subjective, or agree on some 
kind of formal or informal common meaning for it, because i would not 
have put it this way.

'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.

Best regards,

Alexey.




More information about the Python-list mailing list