Return vs. Finally - C# and IronPython
Mike Stall has an interesting new blog entry on the difference between C# and Python regarding returns in finally blocks:
Did you know that returns in finally blocks swallow exceptions in Python? (I didn't):
>>> def f():
... try:
... raise Exception('ouch')
... finally:
... return 3
...
>>> f()
3
>>>
Did you know that returns in finally blocks swallow exceptions in Python? (I didn't):
>>> def f():
... try:
... raise Exception('ouch')
... finally:
... return 3
...
>>> f()
3
>>>
Comments
Post a Comment