Puzzle 6: Explanation
Explore how Python's import system works and why naming your files after standard library modules can cause errors. Understand sys.path, module lookup, and how to safely use relative imports to avoid naming conflicts in your projects.
We'll cover the following...
We'll cover the following...
Let’s try it!
Try executing the code below to verify the results:
Explanation
When Python looks for a module to import (email, for example), it’ll go over the directories in sys.path and try to find a module matching the name. The first value in sys.path is '' (the empty string). The value '' stands for the current directory in which we have the teaser file email.py ...