MCPcopy Index your code
hub / github.com/ipython/ipython / init_sys_modules

Method init_sys_modules

IPython/core/interactiveshell.py:1368–1386  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1366 return user_module, user_ns
1367
1368 def init_sys_modules(self):
1369 # We need to insert into sys.modules something that looks like a
1370 # module but which accesses the IPython namespace, for shelve and
1371 # pickle to work interactively. Normally they rely on getting
1372 # everything out of __main__, but for embedding purposes each IPython
1373 # instance has its own private namespace, so we can't go shoving
1374 # everything into __main__.
1375
1376 # note, however, that we should only do this for non-embedded
1377 # ipythons, which really mimic the __main__.__dict__ with their own
1378 # namespace. Embedded instances, on the other hand, should not do
1379 # this because they need to manage the user local/global namespaces
1380 # only, but they live within a 'normal' __main__ (meaning, they
1381 # shouldn't overtake the execution environment of the script they're
1382 # embedded in).
1383
1384 # This is overridden in the InteractiveShellEmbed subclass to a no-op.
1385 main_name = self.user_module.__name__
1386 sys.modules[main_name] = self.user_module
1387
1388 def init_user_ns(self):
1389 """Initialize all user-visible namespaces to their minimum defaults.

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected