Why Python?
Python is the programming language of choice for many scientists to a large degree because it offers a great deal of power
to analyze and model scientific data with relatively little overhead in terms of learning, installation or development time. It is
a language you can pick up in a weekend, and use for the rest of one's life.
The Python Tutorial (http://docs.python.org/2/tutorial/) is a great place to start getting a feel for the language. To
complement this material, I taught a Python Short Course (http://www.wag.caltech.edu/home/rpm/python_course/) years
ago to a group of computational chemists during a time that I was worried the field was moving too much in the direction of
using canned software rather than developing one's own methods. I wanted to focus on what working scientists needed to
be more productive: parsing output of other programs, building simple models, experimenting with object oriented
programming, extending the language with C, and simple GUIs.
I'm trying to do something very similar here, to cut to the chase and focus on what scientists need. In the last year or so, the
IPython Project (http://ipython.org) has put together a notebook interface that I have found incredibly valuable. A large
number of people have released very good IPython Notebooks that I have taken a huge amount of pleasure reading
through. Some ones that I particularly like include:
Rob Johansson's excellent notebooks (http://jrjohansson.github.io/), including Scientific Computing with Python
(https://github.com/jrjohansson/scientific-python-lectures) and Computational Quantum Physics with QuTiP
(https://github.com/jrjohansson/qutip-lectures) lectures;
XKCD style graphs in matplotlib
(http://nbviewer.ipython.org/url/jakevdp.github.com/downloads/notebooks/XKCD_plots.ipynb);
A collection of Notebooks for using IPython effectively
(https://github.com/ipython/ipython/tree/master/examples/notebooks#a-collection-of-notebooks-for-using-
ipython-effectively)
A gallery of interesting IPython Notebooks (https://github.com/ipython/ipython/wiki/A-gallery-of-interesting-
IPython-Notebooks)
I find IPython notebooks an easy way both to get important work done in my everyday job, as well as to communicate what
I've done, how I've done it, and why it matters to my coworkers. I find myself endlessly sweeping the IPython subreddit
(http://ipython.reddit.com) hoping someone will post a new notebook. In the interest of putting more notebooks out into the
wild for other people to use and enjoy, I thought I would try to recreate some of what I was trying to get across in the
original Python Short Course, updated by 15 years of Python, Numpy, Scipy, Matplotlib, and IPython development, as well
as my own experience in using Python almost every day of this time.
What You Need to Install
There are two branches of current releases in Python: the older-syntax Python 2, and the newer-syntax Python 3. This
schizophrenia is largely intentional: when it became clear that some non-backwards-compatible changes to the language
were necessary, the Python dev-team decided to go through a five-year (or so) transition, during which the new language
features would be introduced and the old language was still actively maintained, to make such a transition as easy as
possible. We're now (2013) past the halfway point, and, IMHO, at the first time when I'm considering making the change to
Python 3.
Nonetheless, I'm going to write these notes with Python 2 in mind, since this is the version of the language that I use in my
day-to-day job, and am most comfortable with. If these notes are important and are valuable to people, I'll be happy to
rewrite the notes using Python 3.
With this in mind, these notes assume you have a Python distribution that includes:
Python (http://www.python.org) version 2.7;
Numpy (http://www.numpy.org), the core numerical extensions for linear algebra and multidimensional arrays;
Scipy (http://www.scipy.org), additional libraries for scientific programming;
Matplotlib (http://matplotlib.sf.net), excellent plotting and graphing libraries;
IPython (http://ipython.org), with the additional libraries required for the notebook interface.
A good, easy to install option that supports Mac, Windows, and Linux, and that has all of these packages (and much more)
is the Entought Python Distribution (https://www.enthought.com/products/epd), also known as EPD, which appears to be
changing its name to Enthought Canopy. Enthought is a commercial company that supports a lot of very good work in