Last active
August 29, 2015 14:16
-
-
Save YS-L/10810953d9c4d8ad7f47 to your computer and use it in GitHub Desktop.
Hack to check the code is executed in an IPython Notebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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