Bug fix: rating can be the string 'None' too.
Replacing range() with slightly more efficient xrange() built-in.