[python-win32] PythonWin - Start in script's directory
Gabriel Genellina
gagenellina at softlab.com.ar
Tue Nov 22 18:35:56 CET 2005
At Tuesday 22/11/2005 14:22, Gregory Piñero wrote:
>I'm not sure how to phrase this question. How can I make PythonWin have
>it's current directory automatically set to the same directory as my script?
>
>For example I want the statement:
>file('test.txt','w')
>to make a file in the same directory as my script, instead of wherever
>PythonWin wants to put it by default, I think somewhere in C:\Python?
os.path.dirname(os.path.abspath(sys.argv[0])) returns the directory where
your script is.
You can make it the current dir using os.chdir
Gabriel Genellina
Softlab SRL
More information about the Python-win32
mailing list