[Tutor] Debugging in emacs

McLaughlin, Toby tmclaughlin at csu.edu.au
Mon Nov 22 00:38:44 CET 2004


Thanks Marilyn,

Debugging in emacs is obviously not the hottest topic around here.

Luckily, I have something working now.  For anyone who is interested,
here is the trick:

1. Add the following to your program:
	import pdb
	pdb.set_trace()
2. Start an interactive Python buffer (C-c !)
3. Run your program (I use C-c C-c)

Emacs picks up the line numbers from set_trace() and marks the
appropriate line in the source buffer.  You can now type 'n' to single
step, as well as issue any of the pdb commands mentioned here:
http://tinyurl.com/3na4u .

The only trouble I have now is that the Python buffer and my source code
keep switching places from top to bottom.  A minor annoyance that
hopefully I will rectify soon.

Toby McLaughlin.

> -----Original Message-----
> From: Marilyn Davis [mailto:marilyn at deliberate.com] 
> Sent: Saturday, 20 November 2004 9:28 AM
> To: McLaughlin, Toby
> Cc: tutor at python.org
> Subject: Re: [Tutor] Debugging in emacs
> 
> 
> On Fri, 19 Nov 2004, McLaughlin, Toby wrote:
> 
> > Hi All,
> > 
> > Could somebody suggest a way to debug python in emacs?  I'd 
> like to be
> > able to single-step while seeing the code marked in some way and
> > possiblly set breakpoints.  I read about using pdb from the 
> command line
> > but would love to have debugging integrated in emacs.  
> Perhaps I should
> > make life easy for myself and use one of the fancy GUI 
> editors, but I
> > think it's character building for me to learn emacs.
> 
> Boy, you could hear a pin drop on this topic.
> 
> I use emacs, even though I have spent some time with idle, because I
> like it much better.  I'm real handy in emacs though, and I don't like
> mousing.  Mice cause lots of repetitive stress injury.
> 
> I spent some time and some email conversations trying to make use of
> the debugger in any environment.  I don't remember what happened
> exactly but I gave up.
> 
> The thing about an interpreted language is that you can say "print
> my_var" in the code instead of in the debugger.  And with emacs, I go
> back and forth between my code and the emacs shell to run it.  I'm
> pretty efficient that way.
> 
> If anyone has any suggestions about debugging, in idle or anywhere, I
> too would love to hear them.
> 
> Thank you.
> 
> Marilyn Davis
> 
> 
> > 
> > Thanks,
> > Toby McLaughlin.
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> > 
> 
> -- 
> 
> 


More information about the Tutor mailing list