MCPcopy Index your code
hub / github.com/RustPython/RustPython / import_module

Function import_module

scripts/whats_left.py:245–259  ·  view source on GitHub ↗
(module_name)

Source from the content-addressed store, hash-verified

243
244
245def import_module(module_name):
246 import io
247 from contextlib import redirect_stdout
248
249 # Importing modules causes ('Constant String', 2, None, 4) and
250 # "Hello world!" to be printed to stdout.
251 f = io.StringIO()
252 with warnings.catch_warnings(), redirect_stdout(f):
253 # ignore warnings caused by importing deprecated modules
254 warnings.filterwarnings("ignore", category=DeprecationWarning)
255 try:
256 module = __import__(module_name)
257 except Exception as e:
258 return e
259 return module
260
261
262def is_child(module, item):

Callers 1

dir_of_mod_or_errorFunction · 0.70

Calls 2

redirect_stdoutClass · 0.90
__import__Function · 0.50

Tested by

no test coverage detected