Since ipython has already been discounted, I’m not sure this answer will be better. But I will tell you the two things that I do.
-
I drop into the debugger at the point where I want to “try out” something, so the code will run up to that point, and then drop me into the debugger. You do this simply by inserting this code at that point:
import pdb; pdb.set_trace()
Once you’ve done what needs to be done, you can either press
q
to quit, orc
to continue running the process. -
I use the
-i
option to python. This enters interactive mode at the end of your python code. This is useful if you want to set up a bunch of data structures, and try out some code on it, instead of typing all of it into a python shell first. (that might be why you rejected ipython?)
solved How to execute my code block by block?