.. _python:
***************
Python Hints
***************
.. contents::
Python is a powerful object-oriented interpreted scripting/programming
language. Some version of Python is almost certainly on your computer
already (on unix, linux, OSX type::
$ python --version
to find out which version, or just::
$ python
to start a python shell with a prompt that looks like::
>>>
You may prefer to use `IPython
`_, which is a nicer shell
than the pure python shell, with things like command completion and history.
See the `Quick IPython Tutorial
`_.
.. _python-install:
Installation of required modules
--------------------------------
To effectively use the pyclaw and Clawpack plotting routines that are
written in Python, you will need version 2.5 or greater
(but **not** 3.0 or above, which is not backwards compatible).
some modules that are not included in the standard Python distribution.
Python modules are loaded with the *import* statement in Python and a wide
variety of specialized modules exist for various purposes since people use
Python for many different purposes.
An alternative to installing the packages discussed below, you could also use the
:ref:`VM`, which has all the required Python modules pre-installed.
For use with Clawpack, you will need the `Numpy
`_ module (*Numerical Python*)
that allows working with arrays in much the same way as in Matlab.
This is distributed as part of
`SciPy `_ (*Scientific Python*).
See the `Installing SciPy http://www.scipy.org/Installing_SciPy>`_
page for tips installing SciPy and NumPy on various platforms.
For plotting you will also need the `matplotlib
`_ module which provides Matlab-like
plotting commands for 1d and 2d plots (e.g. contour and pcolor plots).
This is generally the hardest thing to get going properly. See the
`matplotlib Installation FAQ
`_.
Often the easiest way to get all the modules you need is to install the
`Enthought Python Distribution
`_, which is free for academic
users. Versions are available for Windows, Mac OS X, and Redhat linux.
With some versions of Linux (e.g. debian and Ubuntu), you can easily install
what's needed using ``apt-get``::
$ apt-get install python-numpy
$ apt-get install python-scipy
$ apt-get install python-matplotlib
For OS X, you might also try the `Scipy Superpack
`_.
See also these `tips on installing matplotlib on OS X
`_.
References and tutorials
------------------------
Some useful links to get started learning Python:
* `Enthought Python Distribution `_
* `Dive Into Python `_
* `Python tutorial `_
* `NumPy User Guide `_
* `NumPy for Matlab users `_
* `SciPy Reference Guide `_
* `Matplotlib gallery `_
* `LeVeque's class notes `_
* `Langtangen's book `_ and
`Introductory slides `_
Sage
----
`Sage `_ is an open source mathematics software
collection with its own interface and notebook system. It is based on
Python and the full distribution contains in particular
the Python modules needed for Clawpack.
You can try Sage directly from the
web without downloading, click on "Try Sage Online" link on the
`Sage `_ webpage.
We are working on incorporating Pyclaw into Sage as an optional package.