iter.next()
was removed in python 3. Use next(iter)
instead. So in your example change itertools.cycle().next()
to next(itertools.cycle())
There is a good example here along with various other porting to python 3 tips. It also compares various other next()
idioms in python 2.x vs python 3.x