Add python 2/3 compatibility for 'range'.