[IPython-user] Inconsistency in "!!" ?

Walter Dörwald walter at livinglogic.de
Wed Jun 21 17:18:42 CDT 2006


Asheesh Laroia wrote:

> I want to use ipython for as much as possible, so I thought I would try 
> writing a shell-style for loop.  First I tested !!ls:
> 
>  	In [50]: !!ls
>  	Out[50]:
>  	['common.py',
>  	 'domain.py',
>  	 'histgraph.py',
>  	 'language.py',
>  	 'link-counts.py',
>  	 'link-counts.sh',
>  	 'postprocess.py',
>  	 'sumgen.py',
>  	 'tabgen.py']
> 
> That worked just fine.  So can I loop through these?
> 
>  	In [51]: for thing in !!ls:
>  	------------------------------------------------------------
>  	   File "<ipython console>", line 1
>  	     for thing in !!ls:
>  	                  ^
>  	SyntaxError: invalid syntax
> 
> That's sad.  Is this expected behavior?  Is there some way I can get this 
> to work anyway? (-:

Of course you can always use ipipe for stuff like that:

In [1]: from ipipe import *
In [2]: for f in ils:
    ...:    print f.abspath()
    ...:

or:

In [3]: for f in iglob("*.py"):
    ...:    print f.abspath()
    ...:

For more info see http://projects.scipy.org/ipython/ipython/wiki/UsingIPipe

Servus,
    Walter




More information about the IPython-user mailing list