473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to change current working directory while using pdb within emacs

I have written a pyhton script that will process data file in current
working directory.
My script is in an different directory to data file.
When I debug this script using pdb within emacs, emacs will change the
current working directory to the directory which include the script,
so my script cannot find the data file.

I think this is the problem of emacs because when I start pdb from
console directly, it will not change current working directory to the
one of script being debugged.

please help me.
thank you.
Nov 21 '07 #1
3 8200
duyanning wrote:
I have written a pyhton script that will process data file in current
working directory.
My script is in an different directory to data file.
When I debug this script using pdb within emacs, emacs will change the
current working directory to the directory which include the script,
so my script cannot find the data file.

I think this is the problem of emacs because when I start pdb from
console directly, it will not change current working directory to the
one of script being debugged.
Just issue

import os
os.chdir('whatever')

inside the pdb-session. Unfortunate, but should work.

Diez
Nov 21 '07 #2
On Nov 21, 1:28 pm, "Diez B. Roggisch" <de...@nospam.web.dewrote:
duyanningwrote:
I have written a pyhton script that will process data file in current
working directory.
My script is in an different directory to data file.
When I debug this script using pdb within emacs, emacs will change the
current working directory to the directory which include the script,
so my script cannot find the data file.
I think this is the problem of emacs because when I start pdb from
console directly, it will not change current working directory to the
one of script being debugged.

Just issue

import os
os.chdir('whatever')

inside the pdb-session. Unfortunate, but should work.

Diez
thank you! my friend.
Nov 26 '07 #3
duyanning <du*******@gmail.comwrites:
I have written a pyhton script that will process data file in current
working directory.
My script is in an different directory to data file.
When I debug this script using pdb within emacs, emacs will change the
current working directory to the directory which include the script,
so my script cannot find the data file.

I think this is the problem of emacs because when I start pdb from
console directly, it will not change current working directory to the
one of script being debugged.

please help me.
thank you.
pydb (http://bashdb.sf.net/pydb) has an option to set the current
working directory on invocation. For example, from emacs I can run:

M-x pydb --cd=/tmp --annotate=3 ~/python/hanoi.py 3

And then when I type
import os; os.getcwd()

I get:
'/tmp'

Inside pydb, there is a "cd" command saving you the trouble of
importing os; the "directory" command can be used to set a search path
for source files. All same as you would do in gdb.

Begin digression ---

The --annotate option listed above, is similar to gdb's annotation
mode. It is a very recent addition and is only in CVS. With annotation
mode turned on, the effect is similar to running gdb (gdb-ui.el) in
Emacs 22. Emacs internal buffers track the state of local variables,
breakpoints and the stack automatically as the code progresses. If the
variable pydb-many-windows is set to true, the each of these buffers
appear in a frame.

For those of you who don't start pydb initially bug enter via a call
such as set_trace() or debugger() and do this inside an Emacs comint
shell with pydb-tracking turned on, issue "set annotation 3" same as
you would if you were in gdb.

Nov 27 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John | last post by:
Hi, I'm running a PHP script from a shell (bash, ...) - not from a web server. So I use a script of the form: #!/usr/bin/php <?php var_dump($argv);
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
2
by: Samuel Yin | last post by:
Hi, guys, This should be a simple problem, but I just can not resolve it. I just want to use a python script to change my working directory. see my following code: # mycd.py 1) destdir =...
3
by: Berkflow | last post by:
Anyone know how to change the current working directory in a windows NT service application written in C#? It appears to start in the windows system32 directory not where the exe is located which...
14
by: Vu Pham | last post by:
In order to mark the current address at a given point of the variable block, I use the char dummy as follows : int a; long b; short int c; char dummy; By this way, I can calculate the size...
0
by: Ravi Sundari | last post by:
Need help on the following issue. I am running a console application From within that console application, I would like to change the current directory of the cmd.exe that started the application...
3
by: Chris Mellon | last post by:
This appears to be a change in behavior from Python 2.4 to Python 2.5, which I can't find documented anywhere. It may be windows only, or related to Windows behavior. In 2.4, the current...
8
by: Mateusz Viste | last post by:
Hi, I'm not sure if my question is really related to JavaScript, so please excuse me if that's not the case (and maybe you guys would have an idea what's the cause is and where could I ask)... ...
4
by: cnb | last post by:
I'm trying to switch to using emacs for python. The interpreter and python-mode works but I can't load the file I'm editing into the interpreter. im not sure if c-c c-l is supposed to do that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.