You’ll be able to
- Import from the standard library with
import - Import specific names with
from ... import ... - Organize your own code into reusable modules
- Understand
__name__ == "__main__"for scripts vs libraries
Loading lesson…
Why this matters
Circular imports and misuse of __name__ == "__main__" are the top reasons Django and Flask apps fail to boot. Understanding sys.path, package __init__.py, and relative imports is what makes monorepos and installable packages actually work.
Common pitfalls
- Circular imports from top-level
from x import y— defer imports into function bodies or restructure modules. - Running
python module.pyinside a package — relative imports break; usepython -m package.module. - Shadowing stdlib names like
email.pyortypes.pyin your project — silently breaks unrelated imports.