import next() python 2.5

Viewed 1366

I'm using a slightly altered version of the pairwise recipe from itertools which looks like this

def pairwise(iterable):
    "s -> (s0,s1), (s1,s2), (s2, s3), ..."
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b) 

Now it turns out I need to run the code with python 2.5 where the next() function throws the following exception:

<type 'exceptions.NameError'>: global name 'next' is not defined

Is there a way to use next() with python 2.5? Or how do I need to modify the function to make it work anyhow?

1 Answers
Related