Skip to content

Instantly share code, notes, and snippets.

@Psycojoker
Created May 11, 2018 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Psycojoker/d67c639e5a32b5d019e9b93a045019f4 to your computer and use it in GitHub Desktop.
Save Psycojoker/d67c639e5a32b5d019e9b93a045019f4 to your computer and use it in GitHub Desktop.
finally magic
def brol(fail=False):
try:
print "in try"
if fail:
raise Exception()
return "try"
except:
print "in exception"
return "exception"
finally:
print "in finally"
return "ok"
print brol()
print "====="
print brol(True)
$ python finally.py
in try
in finally
try
=====
in try
in exception
in finally
exception
Press ENTER or type command to continue
in try
in finally
try
=====
in try
in exception
in finally
exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment