Python REPL and Environment Manager

Let's explore the Python REPL and environment manager.

Python REPL

An interpreter is also commonly called a REPL, which refers to the Read-Eval-Print Loop. The simplest approach is to just run Python at the command line. This interpreter is not the most user-friendly.

A popular option is to use Jupyter, an in-browser notebook editor, but it’s advised not to use it for application development.

Using IPython, which is the Python back-end used by Jupyter, is a better option. It has full readline capability, meaning we can use up and down arrows to step through previous commands, or we can search for commands. It keeps a history, which is very useful after tinkering to grab out the commands that we’ve settled on. It also has special commands we can use to time operations, paste without worrying about prompts or auto-indent, and run shell commands from the REPL. Debugging package ipdb that extends the standard debugger pdb with IPython goodness.

To run a script from IPython, we name it on the command line, ipython script.py. If our program takes command-line arguments, and we can indicate to IPython that it should not consume those arguments using the double-dash, as in ipython -- script.py --opt1 arg1 arg2.

We can install Python 3 and IPython on Windows using Chocolatey:

Get hands-on with 1200+ tech skills courses.