Question

I love the IDLE. However, sometimes I have 100-200 line scripts and I want to sort of interactively debug/play with say, functions defined in foo.py instead of just calling python foo.py. Is there a way I can trigger IDLE in the context of my foo.py?

Was it helpful?

Solution

Insert this line into the script:

import pdb; pdb.set_trace()

Which will start the python debugger which lets you step through the script interactively, checking variables and such as you go.

OTHER TIPS

I assume you are asking about how to enable debugging in Idle?

In the Python Shell window, choose Debugger from the Debug menu, then open foo.py and use the Run Model command. A Debug Control window opens, allowing you to step through the execution of foo.py; when execution is over, the prompt is still available for you to manually call functions, interact with objects or otherwise tinker with your application (and you will be still debugging the script).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top