You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think that once the built-in modules are mention above in the post, the recap paragraph:
Let’s recap the order in which Python searches for modules to import:
1. modules in the Python Standard Library (e.g. math, os)
2. modules or packages in a directory specified by sys.path:
1. If the Python interpreter is run interactively:
- sys.path[0] is the empty string ''. This tells Python to search the current working directory from which you launched the interpreter, i.e. the output of pwd on Unix systems.
If we run a script with python <script>.py:
- sys.path[0] is the path to <script>.py
2. directories in the PYTHONPATH environment variable
3. default sys.path locations
could be expressed something like:
Let’s recap the order in which Python searches for modules to import:
1. modules built-in in the Python Standard Library (e.g. math, os)
2. modules or packages in a directory specified by sys.path:
1. If the Python interpreter is run interactively:
- sys.path[0] is the empty string ''. This tells Python to search the current working directory from which you launched the interpreter, i.e. the output of pwd on Unix systems.
If we run a script with python <script>.py:
- sys.path[0] is the path to <script>.py
2. directories in the PYTHONPATH environment variable
3. default sys.path locations.
That is, rest of the modules in the Python Standard Library that are not built-in (e.g. random).
- sys.path[1:], or sys.path[2:] on case PYTHONPATH environment variable exists.
Hope you find it helpful and thanks a lot for your clear and tidy post.
The text was updated successfully, but these errors were encountered:
Hi,
I was reading carefully your great post https://chrisyeh96.github.io/2017/08/08/definitive-guide-python-imports.html because I discovered in it insights that I was for long wanted to clarify.
I think that once the built-in modules are mention above in the post, the recap paragraph:
could be expressed something like:
Hope you find it helpful and thanks a lot for your clear and tidy post.
The text was updated successfully, but these errors were encountered: