[newbie] - How to remain at prompt after script execution?

Fredrik Lundh fredrik at pythonware.com
Mon Feb 14 12:34:18 EST 2005


Amit Dhingra wrote:

> I would like to excute a script and upon completion, how can I just a python
> prompt with the functions and variables already defined.
>
> I know you can do this in the window gui(IDLE). I was wondering if this can
> be done in POSIX systems as well.

does "python -i" do what you want?

$ python -h
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Options and arguments (and corresponding environment variables):
-c cmd : program passed in as string (terminates option list)
-d     : debug output from parser (also PYTHONDEBUG=x)
-E     : ignore environment variables (such as PYTHONPATH)
-h     : print this help message and exit
-i     : inspect interactively after running script, (also PYTHONINSPECT=x)
         and force prompts, even if stdin does not appear to be a terminal
...

$ more myprogram.py
message = "hello, world"
print messae
$ python -i myprogram.py
hello, world
>>> print message.upper()
HELLO, WORLD

</F> 






More information about the Python-list mailing list