getcwd 2.2.1 vs. 2.2.2 and PythonWin

Lexy Zhitenev zhitenev at cs.vsu.ru
Fri Nov 15 05:30:16 EST 2002


> A few days ago, I asked about how to find the directory where my
> script was running.  Someone posted that I should use getcwd.

Not exactly so. os.getcwd returns current dir, and it is not always the dir
where script lies.

> At home, it worked fine with Wing IDE and command line, but getcwd in
> PythonWin would return the directory where PythonWin.Exe was sitting.

By default, the shortcut to PythonWin sets its working dir to
<PythonDir>\site-packages\PythonWin,
so, before you save anything or open, cwd is there, and not in your script
dir.

For an arbitrary module you can get its path by examining module.__file__,
but a script being executed doesn't have it.





More information about the Python-list mailing list