You can use the python -i option to leave the console open at the end of the script.
It allows your script to work until it exits, and you can then look at the variables, call any function and any Python code, including importing and using other modules.
Of course, your script should exit first, either at the end, or if your goal is to debug this part of the script, you can add a call to sys.exit () or os._exit () where you want it to stop (for example, your line fifteen).
For instance:
import os print "Script starting" a=1 def f(x): return x print "Exiting on line 8" os._exit(0)
Usage example:
python -i test_exit.py Scrit starting Exiting on line 8 >>> print a 1 >>> f(4) 4 >>>
source share