Python 3 compatibility: Call `print` as a function
Python 3 compatibility: Use new global `next` function instead of method
Python 3 compatibility: Use `range` instead of `xrange`
Merge branch 'python3-compatibility'