[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-26 Thread Brianvanderburg2 via Python-ideas
I'll have to check that out. It looks like it would work fine for my purposes since I normally run from virtual envs, but could be restrictive in that the user site-packages isn't added. I also found some other mentions of this: https://bugs.python.org/issue33053https://bugs.python.org/issue13475

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread Nick Timkovich
I guess I'm confused if you want (e.g.) `python json.py` to do something but not `python -m json` to call the same file (a different way), given you're in the directory. nick@lappy386:~/Code$ echo "{}" | python -m json.tool {} nick@lappy386:~/Code$ touch json.py nick@lappy386:~/Code$ echo "{}" | p

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread jdveiga
I see... never use this feature. I make extensive use of running modules from local (non-PYTHONPATH) directories. When these modules import (local) sub-modules, the best and simplest method I have found is running them from top directory of the corresponding application. I can run any module in

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread jdveiga
Eryk Sun wrote: > On 2/24/20, jdve...@gmail.com jdve...@gmail.com wrote: > > > > It is the intended and the expected behaviour. The > > working directory is > > always added to the sys.path. > > You mean always in this particular context, i.e. the working directory > is added normally when executin

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread André Roberge
On Mon, Feb 24, 2020 at 6:04 PM Eryk Sun wrote: > On 2/24/20, jdve...@gmail.com wrote: > > > > I try to use along with -m (`python -I -m a.b`) and get this error: > "python: > > Error while finding module specification for 'a.b' (ModuleNotFoundError: > No > > module named 'a')". > > This is a us

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread Eryk Sun
On 2/24/20, jdve...@gmail.com wrote: > > I try to use along with -m (`python -I -m a.b`) and get this error: "python: > Error while finding module specification for 'a.b' (ModuleNotFoundError: No > module named 'a')". This is a use case for -m that requires adding the working directory to sys.pat

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread Eryk Sun
On 2/24/20, jdve...@gmail.com wrote: > > It is the intended and the expected behaviour. The working directory is > always added to the sys.path. You mean always in this particular context, i.e. the working directory is added normally when executing a command via -c or a module as a script via -m.

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread jdveiga
Nick Timkovich wrote: > > Are you familiar with the -I option for "isolated mode"? > https://docs.python.org/3/using/cmdline.html#id2 > -I > Run Python in isolated mode. This also implies -E and -s. In isolated mode > sys.path contains neither the script’s directory nor the user’s > site-packages

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread Nick Timkovich
On Mon, Feb 24, 2020 at 11:51 AM Brianvanderburg2 via Python-ideas < python-ideas@python.org> wrote: > When running a python script directly, the directory of that script gets > added to sys.path. When running as a module "python -m", it looks like an > empty string gets added to sys.path, which

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread jdveiga
Brianvanderburg2 wrote: > This is just an idea, which may not in practice be a major problem but can at > times be > an inconvenience.  I thought I had posted this in the "python -m" thread a > little while > back but checking my history it does't appear I did, I do apologize if this > is a > du