We can use %run to execute a python script inside ipython console (not notebook). However, is there a way we can run the script and have each line of script load and execute as one cell of ipython input. For e.g. if the script is:
if a == b:
print 2*a
if a == 2*b:
print a
Then inside of ipython the script must load (and execute) like so:
In [1]: if a == b:
...: print 2*a
...:
In [2]: if a == 2*b:
...: print a
...:
I don't know if this is even possible, but if so, it will be really helpful as I can load the script and then execute whichever portion of code that I want to execute. A follow up question would be whether we can load the source code of an imported module recursively (like stepping inside a debugger). That way we can make develop and test from within ipython itself, without executing the entire code from scratch (since ipython saves state per cell).