sys.path
The list of folders Python searches, in order, when it imports a module.
In more detail
The first entry is the folder of the script that was run, so a file of your own can shadow a standard module. The first match wins. Because sys.path is an ordinary list, a program can append a folder to it before importing from there.
Example
import sys
sys.path.append('/opt/libs')
import helperRelated terms
- import statement — A statement that makes code from another module or package available by name in the current file.
- module — A file of code whose functions, classes and variables other files can use by importing it.
- sys module — The standard library module through which a program asks the running interpreter about itself.
Taught in
- Import Variants, dir() And sys.path — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Modules Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep