import
KeywordPython 2.0+Beginner
Loads a module or package into the current namespace
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
import math print(math.pi) print(math.sqrt(144)) print(math.ceil(3.2)) import random print(random.randint(1, 10)) import os print(os.name)
import loads a module and makes it available by name. Access its contents with dot notation: module.function().
Try in PlaygroundTags
languagesyntaxcoremodulepackage
Related Items
from
Keyword
Used with import to bring in specific names from a module
as
Keyword
Creates an alias (used with import, with, except)
__import__()
Built-in Function
Low-level function invoked by the import statement
importlib
Stdlib — Introspection
Programmatic import system: dynamic imports, reload, hooks
pip
Ecosystem
The default package installer for Python; downloads from PyPI