{ } Raw JSON

bundles / IPython 9.13.0 / IPython / terminal / embed / embed

function

IPython.terminal.embed:embed

source: /IPython/terminal/embed.py :357

Signature

def   embed ( * header = '' compile_flags = None ** kwargs )

Summary

Call this to embed IPython at the current point in your program.

Extended Summary

The first invocation of this will create a terminal.embed.InteractiveShellEmbed instance and then call it. Consecutive calls just call the already created instance.

If you don't want the kernel to initialize the namespace from the scope of the surrounding function, and/or you want to load full IPython configuration, you probably want IPython.start_ipython() instead.

Here is a simple example

from IPython import embed
a = 10
b = 20
embed(header='First time')
c = 30
d = 40
embed()

Parameters

header : str

Optional header string to print at startup.

compile_flags

Passed to the compile_flags parameter of terminal.embed.InteractiveShellEmbed.mainloop(), which is called when the terminal.embed.InteractiveShellEmbed instance is called.

**kwargs : various, optional

Any other kwargs will be passed to the terminal.embed.InteractiveShellEmbed constructor. Full customization can be done by passing a traitlets Config in as the config argument (see configure_start_ipython and terminal_options).

Aliases

  • IPython.embed

Referenced by