Brian Ray's Blog : Python/IPythonShell.html

Painting is just another way of keeping a diary. --Picasso

Thu, 27 Oct 2005

IPython as primary Shell

IPython , a Python interactive shell developed for the scientific computing community by Fernando Perez is such a powerful tool, I just may replace my default login settings from just bash [1] directly to IPython over bash.

How may people do this? I mean really! Is it practical to cross this line?

If you are new to IPython, there is a decent intro article from ONLamp. Although, I fail to see how this article fits into the LAMP [2] world. Still, it unveils some need features like:

  • magic: Quickly assess special IPython features.
  • Tab Completion: auto-complete code attributes, classnames, methods, and more
  • Introspection: Easy access to Doc Strings and internal documentation
  • History: store a dumpable session of commands
  • Debugger Access: internal access to pdb
  • Run: a safe way to run a file and ignore the __name__ == "__main__", trick
  • Macros: capture command history into a macro

All great stuff. Also mentioned in the article is System Shell Access. For example, you can use cd, pwd, and ls directly in IPython. To escape to the shell use '!' or '!!'.

The IPython Manual notes in the section IPython as system shell. I loose job control if I use iPython this way. Although, I haven't had many issues so far.

Starting IPython with "ipython -p pysh", creates a special enviroment just for shell usages. Usefull in assinging aliases, moving around, and esp capturing varialbes:

bray@chipy[~]|1> $logs = ls *.log
bray@chipy[~]|2> logs.split("\n")
             <2> ['labtest.log', 'try.log', 'untitled-1.log']

In addition, with "ipython -pylab", I can do interactive plots with a fellow ChiPy member's matplotlib. I blogged more about matplotlib. For OSX users, from another ChiPy fixture, Here is some advice on getting matplotlib running.

As ludicrous as it seems, I am unable to find reasonable reasons why not to use IPython as my primary shell.

[1]Bourne Shell (/bin/sh) predecessor, for Bourne Again SHell. :D
[2]LAMP stands for Linux, Apache, MySQL, and [Perl, PHP, or Python] -- a web framework.