Rus Python script interactively

Lie Ryan lie.1296 at gmail.com
Sat Jul 18 18:55:49 CEST 2009


Gnarlodious wrote:
> In an interactive session (I am using iPython), what is the most
> elegant way to run a Python script from Terminal? Right now I am
> saying:
> 
> import subprocess
> subprocess.call("python /path/to/scriptname.py", shell=True)
> 
> But I am calling a shell process and I'd rather not. The script just
> runs, no inputs are needed. Is there a more Pythonesque method?
> 
> -- Gnarlie
> http://Gnarlodious.com/

IMHO, starting a new terminal and runs the script from there.
Or quitting/pausing the current interactive session and run it like
normal python scripts.

Alternatively, you may also want to look at `execfile` built-in function.
>>> execfile('myscript.py', {}, {})




More information about the Python-list mailing list