starting repl programmatically
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Thu May 20 20:20:07 EDT 2010
On Thu, 20 May 2010 16:57:40 -0700, Brendan Miller wrote:
> I have a python script that sets up some environmental stuff. I would
> then like to be able to change back to interactive mode and use that
> environment. What's the best way to do that?
On most(?) Linux distros, `man python` is your friend. (Like all well-
behaviour apps, python should come with a man page.) `python --help` is
useful too, and will be platform independent. Both tell me that you want
to pass -i as an option to enter the interactive interpreter after
running a module or command:
[steve at sylar ~]$ python -c "print 'hello world'; x = 2"
hello world
[steve at sylar ~]$ python -i -c "print 'hello world'; x = 2"
hello world
>>> x
2
You can also set an environment variable to force the same behaviour. See
the help for details.
--
Steven
More information about the Python-list
mailing list