The Python Game Book

code games. learn Python.

User Tools

Site Tools





official documentation:

import is a simple_statement in Python.

Python modules must be imported 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 The 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

en/glossary/i/import.txt · Last modified: 2020/05/16 17:04 by horst