Keep Python Open After Running a Script


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, execute the following at the command line:

python -i

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.

Return to the Tips and Examples index page.

Updated: November 10, 2003 by Johnny Lin <email address>. License.