|
13 | 13 | valid modules that occur later on the module search path. In the simplest case, __init__.py can
|
14 | 14 | just be an empty file, but it can also execute initialization code for the package or set the
|
15 | 15 | __all__ variable, described later.
|
16 |
| -""" |
17 | 16 |
|
18 |
| -# The __init__.py files are required to make Python treat the directories as containing packages; |
19 |
| -# this is done to prevent directories with a common name, such as string, from unintentionally |
20 |
| -# hiding valid modules that occur later on the module search path. In the simplest case, |
21 |
| -# __init__.py can just be an empty file, but it can also execute initialization code for the |
22 |
| -# package or set the __all__ variable, described later. |
| 17 | +When the interpreter executes the import statement, it searches for module in a list of |
| 18 | +directories assembled from the following sources: |
| 19 | +
|
| 20 | +- The directory from which the input script was run or the current directory if the interpreter is |
| 21 | +being run interactively |
| 22 | +- The list of directories contained in the PYTHONPATH environment variable, if it is set. (The |
| 23 | +format for PYTHONPATH is OS-dependent but should mimic the PATH environment variable.) |
| 24 | +- An installation-dependent list of directories configured at the time Python is installed |
| 25 | +
|
| 26 | +The resulting search path is accessible in the Python variable sys.path, which is obtained from a |
| 27 | +module named sys: |
| 28 | +
|
| 29 | +>>> import sys |
| 30 | +>>> sys.path |
| 31 | +
|
| 32 | +@see: https://realpython.com/python-modules-packages/ |
| 33 | +""" |
23 | 34 |
|
24 | 35 | # Users of the package can import individual modules from the package, for example.
|
25 | 36 | import sound_package.effects.echo
|
|
0 commit comments