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

A

Amit Dhingra

I am a total newbie learning the very basics
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.
 
F

Fredrik Lundh

Amit said:
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, worldHELLO, WORLD

</F>
 
A

Amit Dhingra

Thanx Fredrik, that works and thats what I wanted.

Amit

Fredrik Lundh said:
Amit said:
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, worldHELLO, WORLD

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top