The idea is to be able to run the code normally, except it will start an interactive interpreter in the given scope when it gets to a particular method call. Sort of like stopping at a breakpoint to run code.
Ideally, if you are already in an interpreter like ipython, it would return to that interpreter, except with access the current scope in addition to the interpreter scope.
Check out the code module.
Here's an example:
import code
a = 1
b = 2
code.interact(local=locals())
Output:
Python 2.7 (r27:82500, Nov 10 2010, 22:46:43)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> a
1
>>> b
2
>>>
You want code
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With