Python·100 questions

How does module import (import) work in Python?

Answer
import searches for a module in sys.path.
The local project folder is usually at the beginning of sys.path.
__init__.py file makes a folder a package (mandatory in older versions).
Relative imports: from .sub import x.
Avoid cyclic imports.
Was this answer helpful?

More questions in this topic

Related questions from other topics