mirror of
https://github.com/micropython/micropython.git
synced 2025-09-06 09:50:20 +02:00
Return with value gets converted to StopIteration(value). Implementation keeps optimizing against creating of possibly unneeded exception objects, so there're considerable refactoring to implement these features.
11 lines
133 B
Python
11 lines
133 B
Python
def gen():
|
|
yield 1
|
|
return 42
|
|
|
|
g = gen()
|
|
print(next(g))
|
|
try:
|
|
print(next(g))
|
|
except StopIteration as e:
|
|
print(repr(e))
|