Keywords and Control Flow
import — Module loading and name binding
Invoke the import machinery and bind names in the current scope. An ordinary dotted import without an alias binds the top-level package; adding an alias binds the requested module to that alias. The from form binds a requested member. Imports typically reuse modules already in sys.modules, though explicit reloads and custom importers can change behavior. Module initialization may run code and raise exceptions. Import only trusted dependencies; the import statement is not a security boundary.
Formal Syntax & Structure
python syntaxpython
import moduleimport package.submodule as aliasfrom module import memberWorking Example
Example Snippetpython
import mathimport collections.abc as interfacesfrom math import isqrt
print(math.ceil(3.2))print(isqrt(81))print(interfaces.Iterable.__name__)