[python-win32] cwd of program
tim.golden at viacom-outdoor.co.uk
Fri Oct 21 15:42:40 CEST 2005
> I try to get the program's directory, the one where the .exe (or .py)
From within Python, sys.argv usually gives you the running
program (not sure what it does with py2exe etc.). So something
import os, sys
print os.path.dirname (sys.argv)
> With os.getcwd() I get the directory from where the program is
> not his directory. The program has to copy some files and thus I get
> error like "XXXXXX no such file or directory".
Umm. It's not clear why you get "no such file / directory". Surely
os.getcwd returns *some* real directory. Or is it that you don't
have permissions to the directory?
> (the DOS box closed to quickly to have the detailed
> error msg...) where XXXXXX is a sub-directory of
> the program's one.
I'm assuming you're double-clicking on a Python icon to
run the program. You might try, instead, running it from
the command line:
Start > Run > cmd.exe
(DOS box opens)
This should let you see what's going on.
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
More information about the Python-win32