PythonExtra/tests/basics/generator_return.py
Damien George fc1bb51af5 py/objgenerator: Remove TODO about returning gen being called again.
The code implements correct behaviour, as tested by the new test case added
in this commit.
2018-09-27 15:18:24 +10:00

17 lines
285 B
Python

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)