diff --git a/lang/fr/gklearn/utils/isNotebook.py b/lang/fr/gklearn/utils/isNotebook.py new file mode 100644 index 0000000..0491a36 --- /dev/null +++ b/lang/fr/gklearn/utils/isNotebook.py @@ -0,0 +1,16 @@ +""" Functions for python system. +""" + +def isNotebook(): + """check if code is executed in the IPython notebook. + """ + try: + shell = get_ipython().__class__.__name__ + if shell == 'ZMQInteractiveShell': + return True # Jupyter notebook or qtconsole + elif shell == 'TerminalInteractiveShell': + return False # Terminal running IPython + else: + return False # Other type (?) + except NameError: + return False # Probably standard Python interpreter \ No newline at end of file