Skip to content

Instantly share code, notes, and snippets.

@YS-L
Last active August 29, 2015 14:16
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 YS-L/10810953d9c4d8ad7f47 to your computer and use it in GitHub Desktop.
Save YS-L/10810953d9c4d8ad7f47 to your computer and use it in GitHub Desktop.
Hack to check the code is executed in an IPython Notebook
def in_ipynb():
try:
cfg = get_ipython().config
if cfg['IPKernelApp']['parent_appname'] == 'ipython-notebook':
return True
else:
return False
except NameError:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment