[IPython-dev] Re: [IPython-user] Commits to CVS, fixes, and shell access (RFC)

Fernando Perez fperez at colorado.edu
Fri Apr 2 01:37:42 EST 2004


pythondev-dang wrote:
> This sounds great--similar to what I did for my "grep" shell access,
> but generalized.  (I didn't look into storing the results in "hidden"
> variables, but that looks like a good idea also.)

These variables aren't really that 'hidden':  In[N] and Out[N] are always 
there for you, and hopefully the names of the prompts hint at their existence. 
  The magic stuff is that _N==Out[N], and _iN==In[N], and _,__ and ___ hold 
always Out[-1], Out[-2] and Out[-3].  When using ipython for scientific work, 
this kind of caching is incredibly useful.

> I've a question though.  My grep shell extension would capture
> stdout and stderr separately, and wouldn't return stderr, but
> just printed it.  It would then return whatever the command 
> *had* sent to stdout (or None if nothing).  What does @sc do
> for this?

Done.  I've uploaded changes so that now stderr is separately handled:

In [5]: d
lrwxrwxrwx  1 fperez     3 Apr  1 21:49 bar -> foo  ### broken link
-rw-r--r--  1 fperez   124 Oct  6 13:25 die.py
-rwxr-xr-x  1 fperez  9988 Jul  7  2003 divc*
-rwxr-xr-x  1 fperez 11671 Jul  7  2003 divf*

In [6]: !!grep ff *
grep: bar: No such file or directory
Out[6]: ['Binary file divc matches', 'Binary file divf matches']

Note stderr message printed to console before the output is returned.

Thanks again for the feedback.  Hopefully this will provide some relief for 
those interested in ipython having better system integration.

Cheers,

f




More information about the IPython-dev mailing list