Aug-26-2022, 12:13 AM
I have an issue that I found very strange.
Why would invoking Python with '-i' option affect sys.path?
I have two aliases that I use to launch Python:
Is this a bug
Why would invoking Python with '-i' option affect sys.path?
I have two aliases that I use to launch Python:
alias p='python3 ' alias pr='python3 -i ~/.pythonrc'When I use the latter, sys.path does not include '' at the beginning so I cannot load modules from the CWD.
$ pr >>> import sys >>> sys.path ['/home/x', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages', '/usr/lib/python3.9/site-packages'] >>> if I add '' to sys.path it works fine: >>> import sys >>> sys.path.insert(0,'') >>> import koop_db >>>Also, if I call it without the -i option it works fine:
$ p Python 3.9.10 (main, Jan 20 2022, 21:37:52) [GCC 11.2.0] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages', '/usr/lib/python3.9/site-packages'] >>>Does anyone have any idea why it would be designed this way?
Is this a bug