Tuesday, March 30, 2010

IPython

Cool tutorial:
http://showmedo.com/videotutorials/series?name=CnluURUTV
http://showmedo.com/club/joinus?smdc=socb

http://onlamp.com/pub/a/python/2005/01/27/ipython.html

Features

Magic

IPython has several "magic" keywords:
%Exit, %Pprint, %Quit, %alias, %autocall, %autoindent, %automagic, %bookmark, %cd, %color_info, %colors, %config, %dhist, %dirs, %ed, %edit, %env, %hist, %logoff, %logon, %logstart, %logstate, %lsmagic, %macro, %magic, %p, %page, %pdb, %pdef, %pdoc, %pfile, %pinfo, %popd, %profile, %prun, %psource, %pushd, %pwd, %r, %rehash, %rehashx, %reset, %run, %runlog, %save, %sc, %sx, %system_verbose, %unalias, %who, %who_ls, %whos, %xmode

Tab Completion

A very powerful feature in IPython is tab completion. If you are familiar with Python, you may be thinking, The standard Python interactive shell has tab completion. All you have to do is:
[jjones@cerberus ~]$ /usr/local/python24/bin/python Python 2.4 (#2, Nov 30 2004, 09:22:54) [GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import rlcompleter, readline >>> readline.parse_and_bind('tab: complete') >>> 
That's correct. Both the standard Python interpreter and IPython support "regular" completion as well as menu completion. To use completion, type a pattern you would like the shell to match, followed by the Tab key. When in "regular" completion mode (the default), the Tab key will:
  • expand the pattern to as many characters as it can while still honoring the original match criteria
  • list all items matching that pattern
For example:
In [1]: import os  In [2]: os.po os.popen   os.popen2  os.popen3  os.popen4  In [2]: os.popen

2 comments:

Powered by Blogger.