Why IPython is the best thing since sliced bread 15

I recently saw a poll on /r/Python, about how many people used IDLE, which is sort of the default IDE Python comes with. I used IDLE for a long time, but its shortcomings start to catch up with you:

  • Pressing up moves the cursor up, and doesn’t run the last instruction (which is the default behaviour on most command lines)
  • Working with files/directories on your disk is a nightmare (you have to use horrible ways like os.get_cwd or os.chdir).
  • The GUI is ugly. Real ugly

While there are other IDEs, many require you to spend six hours creating a project, when all you want to do is run 5 lines of code.

I discovered IPython by mistake, and ignored it at first. This is because unlike other IDEs, there aren’t people shouting OMG! IPython is the best. Well, it’s time to change that.

OMG! IPython is the Best

IPython is really slick, with a lot of cool features. We’ll only go over a few of them. My goal is to convince you to dump IDLE for IPython.

IPython comes in two flavors: QT Console which runs as a desktop app, and Notebook, which runs as a web service. Let’s looks at QT Console first:

Code completion

If you import a library, say Pandas, and forget which function reads a csv file, pressing tab will give you all possible choices:

ipy1This works with local variables as well:




Great directory/file access

IPython supports most Linux commands, so you can run commands like cd, pwd, ls etc. It makes changing directories, looking up files so easy:




In the example above, I do a pwd, then list all files in the directory using ls, then finally change my directory with cd. Try doing that with IDLE.


Magic features

Another cool feature is that IPython comes with many magic features. These allow you to do things like change directories, which we saw above.

We can also run any Python script from within IPython using %run:


What if you want to run other system commands? Simple, run them by adding a ! to the front. Here is me getting info about my Windows system (by running Windows specific commands):


What if you want to see which variables you have defined?


Or embed your graphs directly within IPython:


There are hundreds of magic commands for everything and anything you could need.

IPython Notebook

The IPython Notebook is another feature that blows you out of the water the first time you use it. It’s power is that you can mix code with Markdown/Latex formatted code. Which means that if you write tutorials, you no longer have to switch between text and code (and neither do your students). Everything is in one place:



Let that sink in for a moment. You can read a tutorial, and run the code, right in the tutorial itself, without having to open another window/shell.

If you change your tutorial, your code gets automatically updated, as they are in the same place.

And not only that, you can share your IPython Notebook as a HTML, Markdown, Rst, and in newer versions, PDF as well.

The future

IPython has evolved into the Jupyter project, which takes IPython and extends it to other languages like R and Julia (for now).

I am waiting for the time when someone writes an entire book purely in IPython. There are a few problems at the moment, but if you know someone who has done this, or trying to do it, please let me know.

Updated based on reader feedback

Ipython can also be run in a pure shell mode. Thanks to Denilson and Simon for pointing that out. Here is an online demo: https://www.python.org/shell/

And as Rachel Thomas points out, there are several books written in Ipython! Here is a selection.

PS: Want a free 1+ hour video course, Introduction to Web Scraping and Data Analysis? Also get a free mini-book, Python: From Apprentice to Master.

* indicates required

I will never spam you. Unsubscribe anytime.

Leave a Reply

15 thoughts on “Why IPython is the best thing since sliced bread