MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / import_module

Function import_module

tools/python-3.11.9-amd64/Lib/importlib/__init__.py:108–126  ·  view source on GitHub ↗

Import a module. The 'package' argument is required when performing a relative import. It specifies the package to use as the anchor point from which to resolve the relative import to an absolute import.

(name, package=None)

Source from the content-addressed store, hash-verified

106
107
108def import_module(name, package=None):
109 """Import a module.
110
111 The 'package' argument is required when performing a relative import. It
112 specifies the package to use as the anchor point from which to resolve the
113 relative import to an absolute import.
114
115 """
116 level = 0
117 if name.startswith('.'):
118 if not package:
119 msg = ("the 'package' argument is required to perform a relative "
120 "import for {!r}")
121 raise TypeError(msg.format(name))
122 for character in name:
123 if character != '.':
124 break
125 level += 1
126 return _bootstrap._gcd_import(name[level:], package, level)
127
128
129_RELOADING = {}

Callers 6

runFunction · 0.90
loadMethod · 0.90
patch_paramsFunction · 0.90
loadMethod · 0.90
_build_backendFunction · 0.90

Calls 2

startswithMethod · 0.80
formatMethod · 0.45

Tested by 1

runFunction · 0.72