0

I'm debugging an script that I'm writing and the result of executing a statement from pdb does not make sense so my natural reaction is to try to trace it with pdb.


To paraphrase: Yo dawg, I like python, so can you put my pdb in my pdb so I can debug while I debug?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Andrew Farrell
  • 2,368
  • 2
  • 22
  • 25
  • Have you tried temporarily putting the statement in the script? – David Z Jun 15 '10 at 20:28
  • Apologies for a somewhat poorly worded question. Actual solution to my problem: when assigning values to variables to test things in pdb, be careful what variable names you use. a = some(expression) + 42 Is not an assignment. Rather, pdb will interperet the 'a' as a command and print all of the arguments to the current function. foo = some(expression) + 42 works I've since found I was solving the wrong problem. – Andrew Farrell Jun 17 '10 at 14:06

1 Answers1

0

It sounds like you're looking for something listed fairly prominently in the docs, which is the set of methods that let you programmatically invoke the debugger on expressions, code in strings, or functions:

I use these when I'm already at the pdb prompt (generally having gotten there by encountering a well-placed pdb.set_trace() statement) and want to test out, for example, variations on some method calls that aren't called in my source but which I can call right in the current context, manually.

If that's not what you were looking for, do you simply want the "step" command instead of the "next" command at the prompt? (It's unclear what you really want here. An example might help.)

Peter Hansen
  • 21,046
  • 5
  • 50
  • 72