iPython is pretty cool

iPython is a powerful, alternative shell for Python. It’s the closest I’ve ever come to the “Lisp experience” in a non-Lisp language. Just as with Emacs or Lisp in general, you get the most leverage out of it by doing as much inside iPython as possible. And iPython can do a lot of things!

The REPL

The iPython REPL is a full-featured shell with readline support. This means you can navigate just as you would in a terminal, search history using ctrl-r, etc.

You can also “dial out” to your regular shell by prefixing a command with !. For example, you can list the contents of the current directory with !ls. You can also save the output of a command:

contents = !ls

Some commands (such as cd) do not work out of the box with the ! operator, as it interferes with the way iPython operates. However, these are made available as regular iPython commands, e.g you can just type cd to change the current directory.

Autocomplete

iPython has powerful autocompletion built in; just press Tab to autocomplete.

Note that autocomplete also works for filenames! This is really useful when you e.g. want to open a file:

# Hit <Tab> to autocomplete the filename!
with open("~/Downloads/foo...") as f:
   print(f.read())

Magics

iPython has a bunch of “magic” commands, usually prefixed with %, that let you interact with iPython itself instead of the running Python session:

Automatically reload imported modules:

%load_ext autoreload
%autoreload 2

Start the debugger on uncaught exceptions:

%pdb

Open $EDITOR to edit the next command:

%edit

View command history (works across sessions):

%history -g

Summary

This is just scratching the surface; you can also do things like displaying images, process audio and video, etc. iPython also provides the kernel of the Jupyter Notebook

If you work with Python in any capacity, I would seriously advise to look into iPython!