
A brief idea of interactive programming using IPython
Python supports interactive computing in multiple programming languages with the help of IPython. IPython is a command shell especially designed for Python programming, and now it supports multiple languages. It offers excellent introspection functionality, new shell syntax, command-line text completion, and command history. Introspection is the capability of programming a command-line environment to examine various characteristics (properties, methods, and other details, such as the superclass). IPython has a number of features, including the following:
- Command-line-based and QT-based interactive shell
- A browser-based notebook that supports coding, mathematical expressions, inline graphics, and graphs
- It also has the capability to support interactive data visualization and other graphical user interfaces
- Support for high-performance parallel computing
IPython parallel computing
IPython has excellent support for parallel and distributed computing to facilitate large-scale computing. It has the capabilities for the development, execution, debugging, and monitoring of parallel or distributed applications. IPython supports most styles of parallelism, including the following, and any hybrid approach made from them:
- Single program multiple data (SPMD) parallelism
- Multiple program multiple data (MIMD) parallelism
- Message Passing Interface (MPI)
- Task and data parallelism
- Custom user-defined approaches
IPython Notebook
IPython Notebook is a Web-based interactive computation environment. This environment is used to create IPython notebooks. It takes single-user inputs or single expressions, evaluates them, and returns the result to the user. This functionality is called read, evaluate, print, and looping (REPL). For REPL, the user can use the following Python libraries:
- IPython
- ØMQ (ZMQ)
- Tornado (web server)
- jQuery
- Bootstrap (frontend framework)
- MathJax
The notebook program creates a local web server on the computer to access it from a web browser. The IPython notebook is a JSON document used to perform different types of computations using coding, text, mathematical operations, graphics, and plotting. These notebooks can be exported to various formats using web-based and command-based options. The supported formats are HTML, LaTeX, PDF, Python, and many more.
The Python notebook development process is presented in the following figure. It starts from the left by preparing the data and then developing the program and its versioning. After the program development, it can be exported to various formats.

Some other remarkable features of IPython are as follows:
- Non-blocking interaction with GUI libraries and toolkits: IPython supports non-blocking interaction with a number of Python-based GUI toolkits/libraries, including Tkinter, PyGTK, PyQt, and wxPython
- Cluster management: IPython supports computing the cluster management facility using MPI/asynchronous status callback messages
- Unix-like environment: The default behavior of IPython is almost similar to that of the Unix shells that support customization of the environment
Tip
Downloading the example code
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
A screenshot of the IPython user interface is depicted here (the source is http://ipython.org/notebook.html):

The user interface of the IPython Notebook interface
The following are various functional features of the IPython command shell:
- Tab completion: The user need not type complete commands. After typing only the initial few characters the remaining command can be completed by pressing Tab.
- Exploring your objects: Various properties of an object can be determined using the introspection facility.
- Magic functions: There are a number of magic functions that can be called by users.
- Running and editing: Users can execute and edit Python scripts from the command shell.
- Debugging: A strong debugging facility is also bundled with the command shell.
- History: The command shell stores the history of commands and their results.
- System shell commands: Users can also use the command provided by the system shell.
- Define your own system aliases: Users can define the aliases of the command as per their preferences.
- Configuration: IPython environment can be customized using the configuration files.
- Startup files: Users can customize the environment to run some commands or code at the beginning of the IPython session.