Skip to content

Instantly share code, notes, and snippets.

@osvalr
Created September 22, 2017 15:45
Show Gist options
  • Save osvalr/ce2e807dfdc1e90661fe2aace04200ef to your computer and use it in GitHub Desktop.
Save osvalr/ce2e807dfdc1e90661fe2aace04200ef to your computer and use it in GitHub Desktop.
#!/usr/sbin/python
def raise_tef(res):
aa = []
try:
print("Raising")
bb = aa[0]
except IndexError:
print("Exception Raised")
return res
finally:
print("Message posted")
print("This is never printed")
res = raise_tef("Expected value")
print("after raise_tef(): %s" % res)
@osvalr
Copy link
Author

osvalr commented Sep 22, 2017

~ ❯ python finally_return.py
Raising
Exception Raised
Message posted
after raise_tef(): Expected value
~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment