I made the following throwaway comment on the CCC GISTEMP mailing list today while talking about the latest 0.6.1 release:

I tried with Python 3.2a2 initially but noticed it won’t run due to syntax errors.

This prompted David Jones to start a new thread:

Ah yes, Python 3. I haven’t done any Python 3 development yet (though I do generally read the release notes). Have you any feel for how difficult it would be to convert to Python 3? This, by the way, is a long way off, it’s just that it would be nice to plan ahead a bit. I’m loathe to do “from __future__ import print_function” at the moment because that doesn’t start working until Python 2.6, and currently we still work with 2.4 and 2.5.

I didn’t have a feel for how difficult it would be, but there was only one way to find out.

Changes

I used the 2to3 tool to convert the code from 2.x syntax into valid 3.x syntax. There was a few additional changes required, mainly to do with calling encode (on strings) and decode (on bytes), and cast some floats to ints.

The last problem I bumped into was the script stalling when trying to extract the files in v2.mean.zip. The problem was in the fetch_zip function. The reading loop was checking for the empty string to determine whether to keep reading from the file. I changed that to check for 0 bytes instead.

Results

It looks like converting CCC GISTEMP to Python 3 will not be a major task. With the work I have done hopefully it’ll be easy to compare results and figure out any discrepancies.