[Python-Dev] Fwd: try...else
Mark Hammond
MarkH@ActiveState.com
Thu, 28 Dec 2000 23:34:09 +1100
Spotted on c.l.python. Although Pythonwin is mentioned, python.exe
gives the same results - as does 1.5.2.
Seems a reasonable question...
[Also, if Robin hasn't been invited to join us here, I think it could
make some sense...]
Mark.
-------- Original Message --------
Subject: try...else
Date: Fri, 22 Dec 2000 18:02:27 +0000
From: Robin Becker <robin@jessikat.fsnet.co.uk>
Newsgroups: comp.lang.python
I had expected that in try: except: else
the else clause always got executed, but it seems not for return
PythonWin 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on
win32.Portions Copyright 1994-2000 Mark Hammond (MarkH@ActiveState.com)
- see 'Help/About PythonWin' for further copyright information.
>>> def bang():
.... try:
.... return 'return value'
.... except:
.... print 'bang failed'
.... else:
.... print 'bang succeeded'
....
>>> bang()
'return value'
>>>
is this a 'feature' or bug. The 2.0 docs seem not to mention
return/continue except for try finally.
--
Robin Becker