Scientists and engineers are used to experimenting. IPython was created by scientists with experimentation in mind. The interactive environment that IPython provides is viewed by many as a direct answer to Matlab, Mathematica, and Maple and R.
Following is a list of features of the IPython shell:
%run
This section describes how to use the IPython shell.
All we need to do is enter the following instruction on the command line:
$ ipython -pylab Type "copyright", "credits" or "license" for more information. IPython 0.12 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. Welcome to pylab, a matplotlib-based Python environment [backend: MacOSX]. For more information, type 'help(pylab)'. In [1]: quit() quit() or Ctrl + D quits the IPython shell.
In [1]: %logstart Activating auto-logging. Current session state plus future input saved. Filename : ipython_log.py Mode : rotate Output logging : False Raw input log : False Timestamping : False State : active
Logging can be switched off as follows:
In [9]: %logoff Switching logging OFF
!
symbol. For instance, the following input will get the current date:In [1]: !date
In fact, any line prefixed with !
is sent to the system shell. Also, we can store the command output, as shown here:
In [2]: thedate = !date In [3]: thedate
%hist
command () for example:In [1]: a = 2 + 2 In [2]: a Out[2]: 4 In [3]: %hist a = 2 + 2 a %hist
This is a common feature in Command Line Interface (CLI) environments. We can also search through the history with the -g switch
In [5]: %hist -g a = 2 1: a = 2 + 2
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. 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.