By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

python execution path

P: n/a
I'm wondering if there is a way to get python to show each line as it
is executed, sort of like sh -x does for shell programs. Seems like
this would be a nice debugging aid.

dustin
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Dustin Lee wrote:
I'm wondering if there is a way to get python to show each line as it
is executed, sort of like sh -x does for shell programs. Seems like
this would be a nice debugging aid.


The best approach, if it's really intended to be a debugging
aid, might be to learn about "pdb", starting perhaps with the
following line inserted shortly above where you think your
bug might be:

import pdb; pdb.set_trace()

(run the code, wait for the prompt, type "?" for help, then
read the docs ;-) )

-Peter
Jul 18 '05 #2

P: n/a
Peter Hansen wrote:
Dustin Lee wrote:
I'm wondering if there is a way to get python to show each line as it is executed, sort of like sh -x does for shell programs. Seems like this would be a nice debugging aid.


The best approach, if it's really intended to be a debugging
aid, might be to learn about "pdb", starting perhaps with the
following line inserted shortly above where you think your
bug might be:

import pdb; pdb.set_trace()

(run the code, wait for the prompt, type "?" for help, then
read the docs ;-) )

-Peter


This is more of a what if-ish question I guess. I use pdb fairly
regularly, I'm just looking to extend my debugging toolkit. I saw an
article recently about how perl has the sh -x type functionality and I
was curious if anything like that was possible in python. Not entirely
sure how it would make my life better, but it seems intriguing.

Jul 18 '05 #3

P: n/a
qh****@gmail.com wrote:
Peter Hansen wrote:
The best approach, if it's really intended to be a debugging
aid, might be to learn about "pdb" ....


This is more of a what if-ish question I guess. I use pdb fairly
regularly, I'm just looking to extend my debugging toolkit. I saw an
article recently about how perl has the sh -x type functionality and I
was curious if anything like that was possible in python. Not entirely
sure how it would make my life better, but it seems intriguing.


Ah. In that case, investigate sys.settrace(). There are doubtless
a variety of recipes and snippets available in either the Cookbook
or in the mailing list archives, after you do the basic reading in
http://www.python.org/doc/2.4/lib/module-sys.html .

-Peter
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.