working directory for debugging in pythonwin

T

Thomas Pfaff

Hello all,

I started using the nice Pythonwin IDE together with Python 2.3 (I have
come to prefer its editor to IDLE).
My problem is, that when I want to run a script in the debugger, I can
give the script name and arguments, but I can't tell it in which
directory it should run.

I googled this group but didn't find anything helpful so far.

I could use some os.chdir in my code, but that's ugly and I neither want
to copy the script around to the places where I would like to test it.

Any suggestions?

Thanks in advance


Thomas
 
C

Colin J. Williams

Thomas said:
Hello all,

I started using the nice Pythonwin IDE together with Python 2.3 (I have
come to prefer its editor to IDLE).
My problem is, that when I want to run a script in the debugger, I can
give the script name and arguments, but I can't tell it in which
directory it should run.

I googled this group but didn't find anything helpful so far.

I could use some os.chdir in my code, but that's ugly and I neither want
to copy the script around to the places where I would like to test it.

Any suggestions?

Thanks in advance


Thomas
Thomas,

When you have initiated PythonWin, try opening (^O) the file you wish to
debug. By selecting the file directory and file you have chosen the
current working directory for the file.

Alternatively, in the Windows Explorer, try right clicking on the py
file you wish to debug. One of the options given is likely to be PythonWin.

Colin W.
 
T

Thomas Pfaff

Colin said:
Thomas,

When you have initiated PythonWin, try opening (^O) the file you wish to
debug. By selecting the file directory and file you have chosen the
current working directory for the file.

Alternatively, in the Windows Explorer, try right clicking on the py
file you wish to debug. One of the options given is likely to be
PythonWin.

Colin W.

Well this is what I do not want to do.
I want to have the script in some folder /source/myscript.py but run it
on data in e.g. /path/to/data/ like I would do on the commandline with

$ cd /path/to/data
$ pypthon /source/myscript.py local-file.dat


Cheers,


Thomas
 
R

Roger Upole

You could pass the directory in as an optional extra argument
to the script. Alternately, you might accept either a bare file name
or a full path.

Roger
 
T

Thomas Pfaff

Roger said:
You could pass the directory in as an optional extra argument
to the script. Alternately, you might accept either a bare file name
or a full path.

Roger

Yes, that's true, and I suppose it's good programming style not to
depend on a special working directory. On the other hand I'd like to
reduce the amount of command line parameters passed into the script, and
I definitely dislike the thought of havin a 'standard' working_dir=
keyword in all my scripts just because my debugger needs it.

Basically I'm used to being able to set an arbitrary working directory
from MS Developer Studio, and I wanted to know before I would contact
Mark Hammond directly, if there is anything else than workarounds for
this problem.

Cheers,


Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top