473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

python execution path

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
3 1735
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
58
by: Svein Ove Aas | last post by:
Is anyone working on a python-to-native compiler? I'd be interested in taking a look. Come to think of it, is anyone working on a sexpr-enabled version of Python, or anything similar? I really...
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
20
by: Mark Carter | last post by:
What I would like to do it type something like > myscript.py instead of > python myscript.py on a Windows console. I know its possible because Ruby scripts manage to do this - I just don't know...
0
by: Robert | last post by:
After failing on a yield/iterator-continuation problem in Python (see below) I tried the Ruby (1.8.2) language first time on that construct: The example tries to convert a block callback interface...
10
by: sandipm | last post by:
Hi, In my application, I have some configurable information which is used by different processes. currently I have stored configration in a conf.py file as name=value pairs, and I am importing...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.