Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > python execution path

Reply
Thread Tools

python execution path

 
 
Dustin Lee
Guest
Posts: n/a
 
      01-17-2005
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
 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      01-18-2005
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
 
Reply With Quote
 
 
 
 
qhfgva@gmail.com
Guest
Posts: n/a
 
      01-18-2005
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.

 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      01-18-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack sndive@gmail.com Python 9 11-14-2007 10:31 PM
Changing the execution path of methods at runtime blufox C Programming 16 06-12-2007 10:57 PM
Deciding execution path based on template parameters? Sachin Garg C++ 3 09-04-2006 04:07 PM
How do I view the runtime execution path of a JIT JVM? David Wake Java 2 02-09-2005 11:53 PM
changing execution path Kris C++ 6 09-18-2003 08:42 PM



Advertisments