for / while else doesn't make sense

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu May 19 19:51:55 EDT 2016


Herkermer Sherwood wrote:
> But there is already a reserved keyword that would work great here.
> "finally".
> 
> Unfortunately, it wouldn't follow the semantics of try/except/else/finally.
> 
> Is it better to follow the semantics used elsewhere in the language, or
> have the language itself make sense semantically?

I think using "finally" this way would be more confusing
than the status quo. Currently, if you see a "finally"
somewhere, it means the block following is always executed
come what may. But with this change, you would need to
look up some arbitrary distance to see whether it belonged
to a "try" or a "for".

It's not so bad with "else" because you need to look back
to find out what condition the "else" refers to anyway.

-- 
Greg
\



More information about the Python-list mailing list