Using IPython

IPython is an enhanced Python REPL, and it’s actually the core for Jupyter notebook. In short, Jupyter is an open-source web application that allows you to create and share documents containing live code, equations, visualizations, and narrative text. If you use the interactive shell a lot and you don’t know IPython, you should really check this one out!

IPython features

Some of the features the IPython shell offers are:

  • Comprehensive object introspection.
  • Input history, persistent across sessions.
  • Caching of output results during a session with automatically generated references.
  • Tab completion, with support for completion of python variables and keywords, filenames, and Python functions.
  • Magic commands for controlling the environment and performing many tasks.
  • Session logging and reloading.
  • Integrated access to the pdb debugger and the Python profiler.
  • A less known feature of IPython: its architecture also allows for parallel and distributed computing.

Magic commands

These are just a selection of the magic commands that are built into IPython that I think you’ll like:

  • %cd — change the current working directory
  • %edit — open an editor and execute the code you typed in after closing the editor
  • %env — show the current environment variables
  • %pip install [pkgs] — install packages without leaving the interactive shell
  • %time and %timeit — time the execution of Python code

Read the full list in the documentation here.

Referencing previous input and output

Another useful feature is referencing the input and output of a previous command. In and Out are actual objects. You can use the output of the 3rd command by using Out[3]. You can re-execute the third command with In[3].

Install IPython

You probably know the drill, but just to be complete, here’s how you install IPython with pip install:

$ pip install ipython

Although it’s often better to use a virtual environment, in this case you may want to install it system-wide or for your entire user account with pip install --user.

Get Certified and advance your career

Our premium courses offer a superior user experience with small, easy-to-digest lessons, progress tracking, quizzes to test your knowledge, and practice sessions. Each course will earn you a downloadable course certificate.

The Python Fundamentals Course For Beginners

Python Fundamentals I is a course for beginners that will get you started with Python in no time. Learn all the essentials, test your progress with quizzes and assignments, and bring it together with the final course project!

The Python Course for Beginners

Modules, Packages, And Virtual Environments

Python Fundamentals II covers creating modules and packages, using virtual environments and Python package managers to make your life as a programmer easier. Advance your productivity as a Python programmer!

Leave a Comment

I hope you’re enjoying my articles. Perhaps you’d like to sign up for my weekly newsletter as well. You’ll receive:

Super easy to unsubscribe & Your data stays on Python Land.

Footer subscribe

No, thanks!

Share to...