File tree Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Open diff view settings
Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Open diff view settings
Original file line number Diff line number Diff line change 1414A module is a file containing Python definitions and statements. The file name is the module name
1515with the suffix .py appended. Within a module, the module’s name (as a string) is available as the
1616value of the global variable __name__.
17+
18+ When the interpreter executes the import statement, it searches for module in a list of
19+ directories assembled from the following sources:
20+
21+ - The directory from which the input script was run or the current directory if the interpreter is
22+ being run interactively
23+ - The list of directories contained in the PYTHONPATH environment variable, if it is set. (The
24+ format for PYTHONPATH is OS-dependent but should mimic the PATH environment variable.)
25+ - An installation-dependent list of directories configured at the time Python is installed
26+
27+ The resulting search path is accessible in the Python variable sys.path, which is obtained from a
28+ module named sys:
29+
30+ >>> import sys
31+ >>> sys.path
32+
33+ @see: https://realpython.com/python-modules-packages/
1734"""
1835
1936# This does not enter the names of the functions defined in fibonacci_module directly in the
Original file line number Diff line number Diff line change 1313valid modules that occur later on the module search path. In the simplest case, __init__.py can
1414just be an empty file, but it can also execute initialization code for the package or set the
1515__all__ variable, described later.
16- """
1716
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+ """
2334
2435# Users of the package can import individual modules from the package, for example.
2536import sound_package .effects .echo
You can’t perform that action at this time.
0 commit comments