Import Import relative and absolute
absolute import must start from the top pack, you must know what the top package in place. Top entry packet is the same level and executable package
relative introduced
. Current
.. superior
... on the upper
....
// import does not support relative import
import .package2 (syntax error will be reported)
from .package2.package4.m2 import m ( )
The reason why the relative path may be positioned according __name__
to a result of the positioning module is executed after the entry of his name is not python his name is the name of the module is forced into python __main__
so python inlet import file may not use a relative path.