Main · Python

This page was last modified on 23 April 2007, at 15:03 NZST

Python is a really nice scripting language that I use for rapid development and prototyping. Python and its Numerical extensions NumPy allow the functionality of ‘Matlab style’ programs, with the advantage of a higher level language and it is for free! There are tools for creating stand-alone versions of the programs, graphical user interfaces, CGI scripting and whatever you may have in mind.

I have started moving my resources to a separate page.

  • Python language home page.
  • Download Python Numerical Extensions (NumPy).
  • NumPy tutorials by David Ascher.
  • Scientific Python: an introduction by Konrad Hinsen.
  • wxPython, a Python interface to wxWindows, a crossplatform GUI developing system.
  • py2exe program to create stand-alone Python applications.
  • Pyrex, a language for writing Python extension modules. Pyrex ‘lets you write code that mixes Python and C data types any way you want, and compiles it into a C extension for Python’.
  • StatPy: Statistical Computing with Python, an excellent list maintained by Tom Loredo.

I used to work with Python quite a bit between 1996 and 1999 (while doing my Ph.D.). However, after that I was mostly doing statistical analyses rather than simulation work. In 2007 I have started again picking up Python and it has changed a lot: it is more mature and consistent. There are a few resources that I think are useful if one is either coming back to it or just starting:

  • The Python tutorial is a good start to remember some of the facilities available in the language. It is also good if you have done very little programming in the past.
  • After reading the tutorial, I think that Dive into Python does a good job at explaining more advanced used of the language.
  • Richard Gruet’s Python Quick Reference is an excellent resource to get a quick idea of how different features of the language work.

From a more practical point of view, I use Python in two of my computers: a macbook pro and a generic windows box.

  • For the former I just installed Python from the official site. OS X comes with Python pre-installed, but it is lagging behind the most recent version. It is a good distribution, but IDLE (the standard Python editor) does not follow the keyboard conventions or mouse scrolling typical in a mac. That aside, it works fine.
  • For the later I use Active State’s distribution, that comes with Pythonwin, an excellent editor.

For my work, NumPy is essential and I was surprised to see that it was so difficult to find a binary version available for OS X. The typical suggestion is to build it yourself using either Macports or Fink. I tried building with Macports, but I did not manage to make it work: it kept building all possible dependencies including a gcc 4.2 compiler! Finally, I found a compiled binary where I should have started looking for: under packages in Pythonmac.

The windows version of NumPy can be easily downloaded from the Numpy home page.