# coding: utf-8 from IPython import embed from IPython.terminal.embed import InteractiveShellEmbed n = 1 print('start embed') embed() # === ipython interactive shell === # # print(n) # => 1 # # n += 1 # # Ctrl + D : exit ipython print('end embed') ipshell = InteractiveShellEmbed() print('start interactive shell') ipshell() # === ipython interactive shell === # # print(n) # => 2 # # Ctrl + D : exit