IPython

Functions

is_ipython

is_ipython()

Function that checks whether the codes (function itself) is executed in ipython kernel or not

Returns:

Type Description
bool

True, if python interpreter is IPython

Source code in fedbiomed/common/ipython.py
def is_ipython() -> bool:
    """
    Function that checks whether the codes (function itself) is executed in ipython kernel or not

    Returns:
        True, if python interpreter is IPython
    """

    ipython_shells = ['ZMQInteractiveShell', 'TerminalInteractiveShell']
    try:
        shell = get_ipython().__class__.__name__
        if shell in ipython_shells:
            return True
        else:
            return False
    except NameError:
        return False