Rus Python script interactively
Peter Otten
__peter__ at web.de
Sat Jul 18 13:13:17 EDT 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?
After a quick glance over ipython's %quickref:
In [1]: !mkdir -p path/to
In [2]: !echo 'print "works!"' > path/to/scriptname.py
In [3]: %run path/to/scriptname.py
works!
More information about the Python-list
mailing list