Python 3 compat: print function.
Python 3 compat: xrange -> range
Python 3 compat: iterators. (This one was a bit tricky.)