backlinks to this page:
Github:
official documentation:
import
is a simple_statement in Python.
Python modules must be import
ed before they can be used. Note that any python program can be imported by another python program, als long as both are in the same directory or some path information is given.
You can import a python module from a subfolder, as long as there exist inside the subfolder a file named __init__.py
. The __init__.py
file can be empty.
You can import only a specific class or function:
from modulename import this from modulename import this, that, another thing
You can import everything from a module using the star, but this is not recommended:
from modulname import *
You can give an alias to a modulename
import very_long_and_complicated_modulename as nickname