python execution path

Discussion in 'Python' started by Dustin Lee, Jan 17, 2005.

  1. Dustin Lee

    Dustin Lee Guest

    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
    Dustin Lee, Jan 17, 2005
    #1
    1. Advertising

  2. Dustin Lee

    Peter Hansen Guest

    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
    Peter Hansen, Jan 18, 2005
    #2
    1. Advertising

  3. Dustin Lee

    Guest

    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.
    , Jan 18, 2005
    #3
  4. Dustin Lee

    Peter Hansen Guest

    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
    Peter Hansen, Jan 18, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Wake
    Replies:
    2
    Views:
    470
    David Wake
    Feb 9, 2005
  2. Kris

    changing execution path

    Kris, Sep 18, 2003, in forum: C++
    Replies:
    6
    Views:
    509
    Kevin Goodsell
    Sep 18, 2003
  3. Sachin Garg
    Replies:
    3
    Views:
    335
    Jerry Coffin
    Sep 4, 2006
  4. blufox
    Replies:
    16
    Views:
    448
    Mark McIntyre
    Jun 12, 2007
  5. Karl von Laudermann

    Execution and dos path woes

    Karl von Laudermann, Oct 28, 2004, in forum: Ruby
    Replies:
    2
    Views:
    132
    Matt Mower
    Oct 28, 2004
Loading...

Share This Page