[Python-ideas] for/else syntax

Gerald Britton gerald.britton at gmail.com
Wed Oct 7 19:40:16 CEST 2009

That's what I was getting at.  As long as Python doesn't crash or the
process is not killed by some external force (e.g. power failure), the
finally clause of a try/except/finally will always be executed.

On Wed, Oct 7, 2009 at 10:18 AM, Masklinn <masklinn at masklinn.net> wrote:
> On 2 Oct 2009, at 03:35 , Greg Ewing wrote:
>> Yuvgoog Greenle wrote:
>>> This
>>> construct should have been named "finally", "didnt_break" or "not break":
>> "finally" would be at least as confusing as "else",
>> since by analogy with try-finally it suggests that
>> it will *always* be executed, which isn't the case.
> Then again, a try's finally isn't *always* executed. It's *almost always*
> executed, but if the runtime (or just the thread the block is in) crashes,
> is killed with kill -9 or the machine is shut down, it won't be.
> Interestingly, because sys.exit throws an exception instead of killing the
> runtime, the finally block does run if you call sys.exit in the try block
> (in Java, it doesn't)
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas

Gerald Britton

More information about the Python-ideas mailing list