1) Introduction

We'll be using Python in the workshop, and it'll save lots of time if, before arriving at the workshop, everyone has this installed and is familiar how to open, edit, and run a script (which is just a text file) using Python.

Furthermore, we'll be using IDLE, Python's own IDE (Integrated Development Environment) — combined source code editor and Python interpreter GUI. The workshop does not rely on any of its specific features, but it makes working with Python on Windows much easier and provides a multi-platform basis for examples.

2) Create a Folder for Workshop Files

No significant storage resources will be required, just a convenient place to browse, download files, create text files, etc. For example, C:\Documents and Settings\MY_USERNAME\My Documents\workshop (Windows), or ~/workshop (Mac/Linux). This is referred to generically as WORKSHOP below.

3) Install Python (and IDLE)

There's a new major release of Python out, version 3. We are not using this — we're using version 2.

Windows

Python and IDLE are not installed by default.

IDLE (Python GUI) and Python (command line) should now by in your program menu, under Python 2.7, and Python will be associated with .py files. However they're going to need to know about the files we create during the workshop. This is easiest if we start IDLE from the WORKSHOP folder itself. Let's create a Windows script, idle.bat that does that:

You should now be able to double-click idle.bat to open IDLE.

Mac

Python is installed by default, but IDLE is not (and Python is likely a little old). Follow these instructions for a Mac binary install, or install from source, using the instructions further down the page.

We're going to want to launch IDLE from within the WORKSHOP directory. This should work by default. Open up Terminal.app from the Applications menu, and type:

cd WORKSHOP

Where WORKSHOP is replaced by the directory you chose to use for the workshop. Now type:

idle &

and hit ENTER to launch IDLE.

Linux

Python is installed by default, but sometimes IDLE is not. Either install IDLE using your distro's package manager, e.g. apt-get install idle (Ubuntu/Debian/etc.), yum install python26-tools (RHEL/CentOS/etc.), USE=tk emerge -avn python (Gentoo), etc., or install new version of Python from source (which will include IDLE).

Launching IDLE from the WORKSHOP directory will be the same as for the Mac case above (just use your favorite terminal instead of Terminal.app).

Alternative Method

On Mac or Linux, you can instead compile Python from source. Instructions are here.

4) Try IDLE

You should now have an IDLE session open that looks something like this:

This is where we'll pick up the workshop. If you're feeling ambitious, try creating a Python script by clicking File -> New Window, which will open a text editor window, and enter the following line:

Click File -> Save and enter hw.py for the filename. Then click Run -> Run Module to run the script:

You have now written and run a Python script.