From f0f0a9c20bc9202bb106fc4f44a5ffbca72c9496 Mon Sep 17 00:00:00 2001 From: linlin Date: Tue, 6 Oct 2020 17:26:46 +0200 Subject: [PATCH] New translations isNotebook.py (Chinese Simplified) --- lang/zh/gklearn/utils/isNotebook.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lang/zh/gklearn/utils/isNotebook.py diff --git a/lang/zh/gklearn/utils/isNotebook.py b/lang/zh/gklearn/utils/isNotebook.py new file mode 100644 index 0000000..0491a36 --- /dev/null +++ b/lang/zh/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