[IPython-user] ipython scripts/noninteractive use?
Fernando Perez
Fernando.Perez at colorado.edu
Thu Nov 24 13:15:25 CST 2005
Jan Nieuwenhuizen wrote:
> I was hoping to use ipython in python scripts to simplify executing
> shell commands, ie, to simplify translating a bash script into python.
>
> For example, how do I use ipython to do something like
This should do:
----------------------------------
#!/usr/bin/env python
from IPython.Shell import IPShell
ipshell = IPShell()
mydir = '~/ipython/test'
ipshell.IP.runlines("""
cd %(mydir)s
!echo $$PWD
ls
""" % locals())
----------------------------------
The ugly extra .IP. attribute is a wart from the current internals. It's
slated for cleanup in the future.
Cheers,
f
More information about the IPython-user
mailing list