Starting a script interactively?

Peter Hansen peter at engcorp.com
Tue Jan 6 14:34:32 CET 2004


David Klaffenbach wrote:
> 
> Is there a way from within a python script to cause the interpreter to
> be in interactive mode after the script finishes?

Added in Python 2.3, according to http://www.python.org/2.3/highlights.html:

PYTHONINSPECT - A program can now set the environment variable $PYTHONINSPECT to 
some string value in Python, and cause the interpreter to enter the interactive 
prompt at program exit, as if Python had been invoked with the -i option. 


In other words, this should work:

import os
os.environ['PYTHONINSPECT'] = '1'

(untested)

-Peter



More information about the Python-list mailing list