How can I interact with rather long python scripts?

python, python-idle

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.

Problem

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`?

Original source