[Python-Dev] package imports, sys.path and os.chdir()

Terry Reedy tjreedy at udel.edu
Sun Apr 29 04:02:06 CEST 2012

On 4/28/2012 3:16 PM, Brett Cannon wrote:

> Who does that? I mean what possible need do you have to start the
> interpreter in one directory, but then need to chdir somewhere else
> where you are doing your actual importing from, and in a way where you
> can't simply attach the directory you want to use into sys.path?

Idle, at least on Windows, when started from the installed icon, starts 
in the directory of the associated pythonw.exe. There is no choice. And 
that is a bad place to put user files for import. So anyone using Idle 
and importing user files does just what you think is strange. Windows 
ain't *nix. If one opens a file in another directory*, that becomes the 
new current directory and imports from that directory work. I would not 
want that to change. I presume that changing '' to '.' would not change 

*and the easiest way to do *that* is from the 'recent files' list. I 
almost never type a path on Windows.

Terry Jan Reedy

More information about the Python-Dev mailing list