When Python evaluates an import such as `import mymod`, it searches the directories listed in `sys.path`. The list contains directory-name strings, and Python checks them in order until it finds a matching module file. section 8.0 section 8.5
The search behavior has two practical consequences:
- Python loads the first matching module and ignores later matches with the same name, so duplicate module names can create conflicts. section 8.0
- You can modify the search locations through `PYTHONPATH` or `.pth` files in the installation's `site-packages` directory. section 8.5
- `sys.path` controls where Python looks; `sys.modules` separately records modules that have already been loaded. section 8.5
Tracing a module import
With `import mymod`, Python looks for `mymod.py` in the directories named by `sys.path`. After finding the first match, it loads that file and stops searching. If another directory also contains `mymod.py`, that second file is not selected. section 8.5 section 8.0


