Sunday, December 16, 2007

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
>>>

No comments:

Post a Comment

Note: only a member of this blog may post a comment.