Minor changes: range->xrange, [].extend(.. for i) -> [... for i]