The purpose of the from
statement is to use things (variables, functions, and
so on) from modules. There are
two general forms:
fromMimport * fromMimportn0,n1, ...
where
is the
name of a Python
module. In the first form, all objects from that module are
added to the local name space. In the second form, only the
named objects M,
n0, ... are added.n1
There are two types of modules:
Python has a number of built-in modules; see commonly used modules below.
You can also create your own modules by simply
placing the definitions of variables and functions in a
file whose name has the form
, and
then using a statement like this:f.py
from f import *Compare this statement with the
import
statement below.