MCPcopy Create free account
hub / github.com/ipython/ipython / embed_kernel

Function embed_kernel

IPython/__init__.py:69–98  ·  view source on GitHub ↗

Embed and start an IPython kernel in a given scope. 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_kernel()` instead. Parameters

(module=None, local_ns=None, **kwargs)

Source from the content-addressed store, hash-verified

67version_info = release.version_info
68
69def embed_kernel(module=None, local_ns=None, **kwargs):
70 """Embed and start an IPython kernel in a given scope.
71
72 If you don't want the kernel to initialize the namespace
73 from the scope of the surrounding function,
74 and/or you want to load full IPython configuration,
75 you probably want `IPython.start_kernel()` instead.
76
77 Parameters
78 ----------
79 module : types.ModuleType, optional
80 The module to load into IPython globals (default: caller)
81 local_ns : dict, optional
82 The namespace to load into IPython user namespace (default: caller)
83
84 kwargs : various, optional
85 Further keyword args are relayed to the IPKernelApp constructor,
86 allowing configuration of the Kernel. Will only have an effect
87 on the first embed_kernel call for a given process.
88 """
89
90 (caller_module, caller_locals) = extract_module_locals(1)
91 if module is None:
92 module = caller_module
93 if local_ns is None:
94 local_ns = caller_locals
95
96 # Only import .zmq when we really need it
97 from ipykernel.embed import embed_kernel as real_embed_kernel
98 real_embed_kernel(module=module, local_ns=local_ns, **kwargs)
99
100def start_ipython(argv=None, **kwargs):
101 """Launch a normal IPython instance (as opposed to embedded)

Callers

nothing calls this directly

Calls 1

extract_module_localsFunction · 0.85

Tested by

no test coverage detected