prompt_config.out_template = 'N.Out<\\#>: '
banner_msg = """
**Nested Interpreter:
Hit Ctrl-D to exit interpreter and continue program.
Note that if you use %kill_embedded, you can fully deactivate
This embedded instance so it will never turn on again"""
exit_msg = '**Leaving Nested interpreter'

def ipsh():
    ipshell = InteractiveShellEmbed(config=cfg, banner1=banner_msg,
        exit_msg=exit_msg)
frame = inspect.currentframe().f_back
msg = 'Stopped at {0.f_code.co_filename} at line {0.f_lineno}'.format(frame)
ipshell(msg, stack_depth=2)
Пошаговая отладка с помощью IPython