How do I run a script from the command line but keep the interpreter session open after the script is done?
Use the -i
option at the command line. Thus,
if your Python script is foo.py
, execute the
following at the command line:
python -i foo.py
You'll want to use this feature if you want to inspect or manipulate the variables from the script, or if you've opened a number of windows and don't want them to close when the Python session terminates at the close of the script.