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

Chris Angelico rosuav at gmail.com
Wed Nov 1 17:21:58 EDT 2017


On Thu, Nov 2, 2017 at 8:12 AM, Alexey Muranov <alexey.muranov at gmail.com> wrote:
> Hello,
>
> what do you think about the idea of replacing "`else`" with "`then`" in the
> contexts of `for` and `try`?
>
> It seems clear that it should be rather "then" than "else."  Compare also
> "try ... then ... finally" with "try ... else ... finally".
>
> Currently, with "else", it is almost impossible to guess the meaning without
> looking into the documentation.
>
> Off course, it should not be changed in Python 3, maybe in Python 4 or 5,
> but in Python 3 `then` could be an alias of `else` in these contexts.
>

The cost of creating a new keyword is incredibly high. You'll need to
demonstrate much more than a marginal improvement.

With try/except/else, it's "do this, and if an exception happens, do
this, else do this". So else makes perfect sense. With the 'for' loop,
it's a bit more arguable, but I've never seen anything more than a
weak argument in favour of 'then', and since it'd be a completely new
keyword, there's very approximately 0% chance that this will be
changed.

ChrisA



More information about the Python-list mailing list