[Python-talk] Writing ipython shell scripts
Lloyd Kvam
python at venix.com
Thu Oct 1 13:30:33 EDT 2009
I had the naive thought that I could take ipython commands, put them in
a file and place a shebang at the top to invoke the ipython interpreter
and I'd be all set.
I spent a couple of hours poking around the ipython web site,
http://ipython.scipy.org/moin/
but found nothing about writing ipython scripts. I suppose that means
they don't support that kind of use. The ipython syntax is a very nice
mix of easy command invocation with python capabilities, so I'm
surprised script execution is not supported.
Did I just not see it??? I'm hoping one of you knows the answer.
My simple test example is shown below.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[lkvam at www ~]$ ipy-test
------------------------------------------------------------
File "/home/lkvam/bin/ipy-test", line 3
myfiles = !ls ~/
^
SyntaxError: invalid syntax
WARNING: Failure executing file: </home/lkvam/bin/ipy-test>
IPython 0.8.4 [on Py 2.5.2]
[~]|1> #! /usr/bin/ipython
[~]|2>
[~]|3> myfiles = !ls ~/
[~]|4> for f in myfiles:
|.> if f.endswith('.py'):
|.> print f
|.>
csv2sql.py
weather.py
[~]|5> cat bin/ipy-test
#! /usr/bin/ipython
myfiles = !ls ~/
for f in myfiles:
if f.endswith('.py'):
print f
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
--
Lloyd Kvam
Venix Corp
DLSLUG/GNHLUG library
http://dlslug.org/library.html
http://www.librarything.com/catalog/dlslug
http://www.librarything.com/rsshtml/recent/dlslug
http://www.librarything.com/rss/recent/dlslug
More information about the Python-talk
mailing list