debugging

jsolbrig at my-deja.com jsolbrig at my-deja.com
Mon May 29 02:51:16 CEST 2000


In article <ba3Y4.5208$SY5.23052 at newscontent-01.sprint.ca>,
  "Reza Habib" <reza at psych.utoronto.ca> wrote:
> Hello.  I'm new to python and am having some trouble debugging my
program.
> I'm running python 1.52 under windows nt 4 sp6.  I use the python
command
> line shell to import my script file, the pdb file, and then start the
> debugger: pdb.run('myfile.test()').  This starts the debugger,
however, the
> list command only prints EOF.  Also, I can't set breakpoints by giving
line
> numbers (since it doesn't look like the file was loaded).  However, if
I use
> the next command, it will correctly step through my code.

Step a couple times and then try giving the line breaks. I have found
that break point within the pdb command line can be buggy. Sometimes pdb
just ignores your breaks (I submitted this as a bug some month ago -
perhaps if you have code you can isolate it in you could send it).
Also, pdb can be fairly slow, depending on your machine and size of your
code. I haven't found any trouble with list once a file is loaded - have
you tried this?

You can insert calls to the debugger (break-points) directly into your
code - just put the statement pdb.Pdb().set_trace() where you want to
stop and be sure that stdin and stdout point to the dos box you are
running the app in. This will get you to your break point fast. (The
statement pdb.set_trace() leaves you one level deeper in the stack.)
You can even add debugging logic to the code such
if foo:
   Pdb.Pdb().set_trace() #break to be removed

(The debugger supports direct conditional breaks as well).

It would be nice if the windows command line had something like doskey.
But alas. Using the command p foo.__dict__ is good for finding what is
happening with everything inside an object and creating __str__ methods
for your objects also helps.

Anyway, these are my tips. Good luck and, also I think the rest of your
questions can be answered by the documentation of the pdb module.

Joe Solbrig
python hacker available for assignment


>Is there
> something I need to do to get the list command to work so that I know
where
> in the code I'm debugging and also to get break points to work.
Thanks in
> advance.
>
> Reza
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list