Skip to content

Instantly share code, notes, and snippets.

@ralphsmith80
Last active August 9, 2017 17:33
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 ralphsmith80/1c1e40fcadcb18dec498736efd163ff7 to your computer and use it in GitHub Desktop.
Save ralphsmith80/1c1e40fcadcb18dec498736efd163ff7 to your computer and use it in GitHub Desktop.
Get code after sys.exit()
import sys
def something():
print("Kenny lives")
sys.exit()
print("Can you see me")
if __name__ == '__main__':
# only code here
def noop():
def exit():
pass
sys.exit = noop
something()
# output:
# Kenny lives
# Can you see me
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment