Modules, Imports & Essential Stdlib
Unit 4: Files, Exceptions & Standard Library · 7 min read
How sys.modules and sys.path resolve imports, why __name__ == '__main__' guards matter, and practical tools in itertools, math, and re.
Key Concepts
- sys.modules caching and circular import avoidance
- Never name a script math.py, json.py, or random.py
- Absolute vs package-relative imports
- High-leverage stdlib: collections, heapq, bisect, itertools