Entering Python’s Interactive ModeDecember 14, 2016
You can drop into Python’s interactive mode immediately after executing a script. Say you have the following script,
message = 'Hello, World!'
foo.py then immediately enter interactive mode, use the Python interpreter’s
$ python -i foo.py >>> message 'Hello, World!'
This is a nice way to avoid repeatedly typing the same commands when developing a script or experimenting with something new. You can achieve a similar effect by setting a breakpoint in your script, though I prefer the
-i option when I don’t want to end up in the debugger.