def embed_interactive(**kwargs):
    """Embed an interactive terminal into a running python process
    """
    if 'state' not in kwargs:
        kwargs['state'] = state
    if 'conf' not in kwargs:
        kwargs['conf'] = conf

    try:
        import IPython
        ipython_config = IPython.Config()
        ipython_config.TerminalInteractiveShell.confirm_exit = False
        if int(IPython.__version__.split(".")[0]) < 3:
            IPython.embed(config=ipython_config,
                          banner1='',
                          user_ns=kwargs)
        else:
            IPython.embed(config=ipython_config,
                          banner1='',
                          local_ns=kwargs)
    except __HOLE__:
        import readline  # pylint: disable=unused-variable
        import code

        code.InteractiveConsole(kwargs).interact()
dataset/ETHPy150Open duerrp/pyexperiment/pyexperiment/utils/interactive.py/embed_interactive