Open valentinsulzer opened 4 years ago
When using a notebook, it makes more sense to record the cell number than the name of the file. It might be possible to:
def is_notebook(): try: shell = get_ipython().__class__.__name__ if shell == "ZMQInteractiveShell": # pragma: no cover # Jupyter notebook or qtconsole cfg = get_ipython().config nb = len(cfg["InteractiveShell"].keys()) == 0 return nb elif shell == "TerminalInteractiveShell": # pragma: no cover return False # Terminal running IPython elif shell == "Shell": # pragma: no cover return True # Google Colab notebook else: return False # Other type (?) except NameError: return False # Probably standard Python interpreter
get_ipython().execution_count
When using a notebook, it makes more sense to record the cell number than the name of the file. It might be possible to:
get_ipython().execution_count
)