4 ms·
If you run a script, such as "pip", sys.path[0] is the script's directory, not cwd: https://docs.python.org/3/using/cmdline.html https://docs.python.org/3/usin
by jwilk 4y ago
If you run a script, such as "pip", sys.path[0] is the script's directory, not cwd:
https://docs.python.org/3/using/cmdline.html https://docs.python.org/3/using/cmdline.html
> If the script name refers directly to a Python file, the directory containing that file is added to the start of sys.path
- romanows 4y agoYou are right! I missed the switch from talking about the `python -m`-style invocation versus the `python <script>`-style invocation. (Should I double down and attribute it to difficulties with how significant whitespace indentation can make it hard to determine the scope (of the comment threading on mobile)? :P)