theme of the week: tools

Fernando Perez fperez528 at yahoo.com
Sun Sep 26 17:36:59 EDT 2004


Jeremy Jones wrote:

> Another tool that I use that I just started using but I'm finding
> indispensable is IPython.  Features:

<blush> :)  I'm glad you like it, though.

>     * tab completion - this is probably the hugest benefit.
>     * executes (some? all?) OS commands without having the exit out -
>       tab completion works on filesystem paths here

The @rehash magic command will load _all_ of your $PATH as aliases, by default
only the most common things are loaded.  You can just type alias to see what's
active.  Note that the pysh profile (ipython -p pysh) preloads your whole path,
and adds a few more modifications, so you can use ipython as a system shell,
but with python syntax (and full two-way communication of variables).  Here's
an example:

fperez at maqroll[~/test]|8> $$files=ls
fperez at maqroll[~/test]|9> type(files)
                      <9> <type 'list'>
fperez at maqroll[~/test]|10> len files
-------------------------> len(files)
                      <10> 33
fperez at maqroll[~/test]|11> for f in files:
                      |..>     if len(f) > 10:
                      |..>         wc -l $f
                      |..>
      4 inspectbug.py
     73 ramptest.py

Granted, it's silly, but I don't know in the shell how I could easily say "run
wc -l over all files whose name is longer than 10 characters".  I can _never_
remember how to do complicated logic/looping in the shell, while I can
certainly do such things trivially in python.  The pysh profile puts ipython in
a mode which bridges this gap.  Incidentally, pysh is actually just a special
configuration mode for ipython, consisting of about only 36 lines of code (the
rest is regular ipython).

>     * probably more....but I'm still digging into this

Lots more :)

Best,

f




More information about the Python-list mailing list