def paired_iter(it):
    token = next(it)
for lookahead in it:
    yield token, lookahead
token = lookahead
yield token, None

def scan(s):
    for c in s:
        yield c
for this_token, next_token in paired_iter(scan('ABCDEF')):
    pass
Использование опережающего просмотра с генераторами