Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a10986a

Browse files
committed
add IPython.start_kernel
for symmetry
1 parent bc17e08 commit a10986a

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

IPython/__init__.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@
6161
def embed_kernel(module=None, local_ns=None, **kwargs):
6262
"""Embed and start an IPython kernel in a given scope.
6363
64+
If you don't want the kernel to initialize the namespace
65+
from the scope of the surrounding function,
66+
and/or you want to load full IPython configuration,
67+
you probably want `IPython.start_kernel()` instead.
68+
69+
6470
Parameters
6571
----------
6672
module : ModuleType, optional
@@ -112,3 +118,30 @@ def start_ipython(argv=None, **kwargs):
112118
"""
113119
from IPython.terminal.ipapp import launch_new_instance
114120
return launch_new_instance(argv=argv, **kwargs)
121+
122+
def start_kernel(argv=None, **kwargs):
123+
"""Launch a normal IPython kernel instance (as opposed to embedded)
124+
125+
`IPython.embed_kernel()` puts a shell in a particular calling scope,
126+
such as a function or method for debugging purposes,
127+
which is often not desirable.
128+
129+
`start_kernel()` does full, regular IPython initialization,
130+
including loading startup files, configuration, etc.
131+
much of which is skipped by `embed()`.
132+
133+
Parameters
134+
----------
135+
136+
argv : list or None, optional
137+
If unspecified or None, IPython will parse command-line options from sys.argv.
138+
To prevent any command-line parsing, pass an empty list: `argv=[]`.
139+
user_ns : dict, optional
140+
specify this dictionary to initialize the IPython user namespace with particular values.
141+
kwargs : various, optional
142+
Any other kwargs will be passed to the Application constructor,
143+
such as `config`.
144+
"""
145+
from IPython.kernel.zmq.kernelapp import launch_new_instance
146+
return launch_new_instance(argv=argv, **kwargs)
147+

0 commit comments

Comments
 (0)