examples/generators/fibonacci_generator.py
from __future__ import print_function

def fibonacci():
    a, b = 0, 1
    while (True):
        a, b = b, a+b
        yield a

for a in fibonacci():
    print(a)
    if a % 17 == 0:
        print('found')
        break

    if a > 200:
        print('not found')
        break

The fibonacci() function is called 5 times. When it reached the 'yield' command it returns the value as if it was a normal return call, but when the function is called again, it will be executed starting from the next statement. Hence the word 'after' will be printed after each call.