[IPython-user] SList.grep - one more little utility for 0.8.2

Ville M. Vainio vivainio@gmail....
Fri Sep 7 10:04:09 CDT 2007


Since SList's are now much more common (due to a = !syscmd, mglob etc
returning them) I added a nifty little utility to SList: grep.

Here's how it works:

[~/ipython]|15> a = !cat README
 ==
['Please see the doc/ directory for full manuals and other documents.
The manual is',

...


[~/ipython]|19> ;a.grep install
--------------> a.grep("install")
           <19> SList (.p, .n, .l, .s, .grep available). Value:
0: These manuals normally get installed to
$PREFIX/share/doc/ipython-VERSION, unless you
1: redirect the installer via a --prefix/--home option.  Normally, $PREFIX is
2: /usr, but your Python may be installed elsewhere.  You can see its value by
[~/ipython]|20> _.grep('prefix', prune = 1)
           <20> SList (.p, .n, .l, .s, .grep available). Value:
0: /usr, but your Python may be installed elsewhere.  You can see its value by
[~/ipython]|21> svn diff

I suppose the usefullness of this for file list / text data
manipulation is obvious. No more need to do those list comprehensions.

It's late in the release cycle, but very useful for tons of common problems.

-- 
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'


More information about the IPython-user mailing list