When I was just peeping into the discussions at #python, I saw a few talking about ipython. On first look, I thought it to be Iron Python stuff but was wrong. It is an (another?) enhanced Python Shell or what we otherwise call as Interactive Python Mode. The good thing with these stuffs is you can just download and try them, not much a paining process to get them working. Hence I went for it.
- Dynamic Object Introspection : We can access docstrings, function definition prototypes, source codes of modules, source files and a lot more dynamically.
For example, after importing `os` module, typing os.path?? or os.path? gives complete source code and description of the os module respectively. Similarly `%pdoc object`gives us the object’s doctstring information.
- Local namespace completion with TAB press.
- Numbered input/output prompts.
In : print "Hello World!"
In : (1+2)*3
- User-extensible`magic` commands (type %magic for information).
- System shell access with ! prefix.
!ls will issue the `ls` command in the system shell and print its output.
- File system navigation with %cd command.
- Verbose and colored exception traceback.
>>> callable_ob arg1, arg2, arg3
and the input will be translated to this:
--> callable_ob(arg1, arg2, arg3)
>>> ,my_function a b c # becomes my_function("a","b","c")
>>> ;my_function a b c # becomes my_function("a b c")
- Embeddable within other python code/modules.
I always prefer the `svn checkout` way of getting the source code. We can get to know more about ipython at its home site. We can also get pythonreadline from the same site, which helps us to have features like color, tab, completion, etc. (I read somewhere that it is not needed for ipython as it implicitly has pyreadline). The following are the steps to install ipython from the svn repos as a local copy,
- We can get the source code by doing an svn checkout,
- We need to get into the checked out source directory and run the following command
- The –home option can be used to specify a directory to install the ipython, else it will install in the default python directories.
- If we are using –home option, then we need to add the following line into our.bashrc. Else we need to export the PYTHONPATH variable every time adding the path of our ipython/lib/python installation to it.
- We can run ipython by executing ipython/bin/ipython from the shell (or create a link pointing to this file).
svn co http://ipython.scipy.org/svn/ipython/ipython/trunk ipython
python setup.py install
python setup.py install --home /home/myuser/python/ipython