James C. Ahlstrom writes: | | The proposal is to put getcwd() into sys.path[0] for an interactive | interpreter. So after os.chdir(), imports would NOT be made from | the new current directory, but rather from the original current | directory. | | If this is a problem (I'm guessing it is) then the new rule would be: | | sys.path[0] is the absolute path to the script if there is one; else | for an interactive interpreter or for the "-c" option, sys.path[0] | is the special entry "" (or perhaps ".") that means look in the | current directory (which is allowed to change). | | In either case, sys.path[0] would be added before any imports. | | I am not happy with changing current directories because I am trying | to speed up imports, and it is harder to cache directory contents | on multiple operating systems. But I can do it if we need to. | | A special case for "." is not too bad, but accommodating arbitrary | relative paths is more of a problem. | | What do others think? | As little as I like it, we have lots and lots of code here that depends on chdir to find modules for importing. If you were to make this change (and I suspect you won't because it might break lots of code, but for argument's sake...) would having an explicit '.' somewhere in sys.path still work after a chdir?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4