aboutsummaryrefslogtreecommitdiff
path: root/tests/basics/generator_return.py
blob: 2b3464a02aec5901edaf94cd8c00f3a5549eb4be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def gen():
    yield 1
    return 42

g = gen()
print(next(g))
try:
    print(next(g))
except StopIteration as e:
    print(type(e), e.args)

# trying next again should raise StopIteration with no arguments
try:
    print(next(g))
except StopIteration as e:
    print(type(e), e.args)