replacing `else` with `then` in `for` and `try`
Chris Angelico
rosuav at gmail.com
Thu Nov 2 04:29:51 EDT 2017
On Thu, Nov 2, 2017 at 7:05 PM, Alexey Muranov <alexey.muranov at gmail.com> wrote:
> On Wed, 2017-11-01 at 21:30 +0000, Stefan Ram wrote:
>>
>> >
>> > In languages like Algol 68, »then« is used for a clause
>> > that is to be executed when the main condition of an
>> > if-statement /is/ true, so this might cause some confusion.
>> >
>
>
> sure, and `else` is used for a clause that is to be executed when the main
> condition of `if` is false.
>
> So, in
>
> try:
> do_something
> except:
> catch_exception
> else:
> continue_doing_something
>
> when no exception occurs in `do_something`, is `do_something` more true, or
> more false?
It's neither. It didn't happen. That's the whole point of exceptions -
they aren't about normal flow and normal values, they are
fundamentally different. But if you like, consider this kind of model:
caught_exception = catch {{{
do_something
}}}
if caught_exception is not None:
handle_exception
else:
continue_doing_something
The caught exception is either a thing, or not a thing.
ChrisA
More information about the Python-list
mailing list