using python debugger (pdb) inside emacs debugger mode ...

Alex alex at somewhere.round.here
Tue Sep 14 13:41:31 EDT 1999


I had the same problem for a while.  I got a partial solution going, but
gave up when I decided that it was easier to just insert a
pdb.set_trace() in the region of code I was interested in.

Anyway, what I did was set 

(setq gud-pdb-command-name "python ~/command-pdb.py ")

where command-pdb.py contained:

#!/usr/bin/python
import sys, pdb, re
home = '/home/alex/'
file = sys.argv[1]
file = re.sub ('^~', home, file)
sys.path = [re.match ('(.*)/[^/]*$', file).group (1)] + sys.path
pdb.run ('import ' + re.match ('.*/([^/]*)\.py$', file).group (1))

so when I ran pdb, in the command line would appear

Run pdb (like this): python command-pdb.py 

and I would enter the path to the script I wanted to run, i.e. if it was
in ~/python/script.py, I would put that whole path in, regardless of
what the cwd was.

It was then easy to bind a function key to some emacs lisp that did all
this automatically for the buffer I was currently in.  Unfortunately, I
seem to have deleted that while noodling around with my .emacs file.
Probably just as well, because it was at least as bad as the code
above. :)

Alex.

-- 
If cars were like computers, they would go 300 m.p.h. and get a hundred
miles to the gallon and cost $50. Except that twice a month someone a
thousand miles away would be able to blow up the car, killing everyone
nearby.




More information about the Python-list mailing list