Python help

Introduction

Python is a modern computer language that is very easy to learn. Python is used for simple scripting but also for huge research projects, in physics [1], and other sciences see [2]. Among the many excellent books on Python, we recommend the following [3]

Python: Dialects and versions, libraries

In order to write your own Python programs and to run the ones on this site, you must install some free software.
  1. Python Version 2.6 or 2.7 (not 3.x, these versions being considered too new for general users): This is the programming language
  2. Matplotlib. This library has a feel similar to matlib. It allows to produce very nice plots, histograms, 3d, etc.
  3. NumPy: This library contains useful numerical routines (matrices, linear algebra, optimization routines, etc).

Installing Python

Linux

On Linux, the installation of Python (with numpy and pylab) is quasi automatic.

Ubuntu

On Ubuntu, for example, you go to the Synaptic package manager, make sure that you are online, and then simply click on the relevant packages. A snapshot of the download window is shown here.
Kubuntu_synaptic_snapshot.png

Debian

On Debian, type as root the following command on a shell
aptitude install python python-numpy python-matplotlib

Windows and Mac

  • Installation help for Mac Snow Leopard, Mac Leopard and Windows: http://www.cgl.ucsf.edu/Outreach/pc204/matplotlib.html (University of California at San Francisco)
  • Another possibility consists is using a (free) Linux virtual box:
    • Download and install VirtualBox [1]
    • For MacOsX 10.4 et 10.5, use version 4.1.18 from [2]
    • Download and uncompress the Linux Student image [3] (1 Gb!)
    • Install it by double-clicking on the file LinuxStudent.VBOX (or with Machine > Add > LinuxStudent.VBOX )
    • Launch the VirtualBox
    • The password to start Linux is "student" ; use a konsole command line to start python
    • If you use a US keyboard, type: sudo setxkbmap us

Useful Websites

Python documentation: http://docs.python.org Python in 10 Minutes: http://www.poromenos.org/tutorials/python

References

  1. PyPhy - Python in Physics 2011, August 29, 2011, ENS, Paris
  2. 4th European Meeting of Python in Science (Euroscipy 2011) , on August 25-28, 2011
  3. M. Lutz Learning Python 4th edition (O'Reilly)