[Python-ideas] Interactive trace function
Gerald Britton
gerald.britton at gmail.com
Fri Mar 20 18:53:36 CET 2009
Thanks for the tip! btw, did you get the --ignore-dir option to work?
I'm trying to run this on a large system (hundreds of modules) and
ignore most of the modules and packages to focus on just a few.
However, it processes all of them anyway
On Fri, Mar 20, 2009 at 1:02 PM, R. David Murray <rdmurray at bitdance.com> wrote:
> Jacob Holm <jh at improva.dk> wrote:
>> Gerald Britton wrote:
>> > Years ago I worked for a while in REXX. It was a fairly advanced
>> > scripting language for its time and we used it on some substantial
>> > mainframe projects. One thing that I liked and miss in Python is the
>> > "trace" statement.
>> >
>> > Basically, you could insert a "trace" statement in a REXX program and
>> > then, when you ran it, it would step through the program a line at a
>> > time. This gave you the chance to follow your code through tricky
>> > sections and display variables after each step. I know it saved me
>> > hours of troubleshooting of tricky problems.
>> >
>> > I would like to know if anyone has ever proposed something similar for
>> > Python. It would work something like this:
>> >
>> > 1. In an interactive session, you could issue a trace command.
>> > Thereafter, whatever you ran would be done a step at a time, with a
>> > terminal prompt after every statement for you to print anything you
>> > like that would help you understand the state of the program at that
>> > point.
>> >
>> > 2. From the command line, you could add a --trace option, or something
>> > like it, to ask Python to launch the program interactively with trace
>> > enabled, which would work as described above.
>> >
>> > 3. If you have a problematic piece of code, you could insert a trace
>> > statement just before the troubled section. Then when you ran the
>> > program, when it came to the trace statement, it would begin an
>> > interactive trace at that point as described above. (You would have to
>> > start your program from the command line for this to make sense.)
>> >
>> > Has something like this ever come up before? Is there a way to do this today?
>> >
>> >
>> >
>> How about:
>>
>> import pdb; pdb.set_trace()
>>
>> I use that for debugging all the time...
>
> I just learned about this one, which is also sometimes useful (when you
> _don't_ want the interactive prompt, you just want to see the sequence
> of execution):
>
> python -m trace -t <pythonprogram>
>
> --
> R. David Murray http://www.bitdance.com
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
--
Gerald Britton
More information about the Python-ideas
mailing list