CKTIS / Python
Keyword import
Locate and initialize a module if necessary, then bind a name in the current namespace.
Version: Python 3.14; repository image, production runtime not attested
Syntax
import package.module; import package.module as aliasLocate and initialize a module if necessary, then bind a name in the current namespace.
Repeat imports normally reuse the object in sys.modules. Importing a dotted module without an alias binds its top-level package, while an explicit alias denotes the named submodule.
Removing a local binding leaves the module cache intact.
Examples
import xml.etree.ElementTree
import xml.etree.ElementTree as tree
import sys
print(xml.__name__, tree.__name__)
del tree
import xml.etree.ElementTree as again
print(again is sys.modules["xml.etree.ElementTree"])
Result
xml xml.etree.ElementTree True
Removing a local binding leaves the module cache intact.