2018-04-01 18:15:35 +01:00
|
|
|
# test deeply recursive generators
|
|
|
|
|
2018-04-10 05:39:51 +01:00
|
|
|
# simple "yield from" recursion
|
2018-04-01 18:15:35 +01:00
|
|
|
def gen():
|
|
|
|
yield from gen()
|
2020-03-23 02:26:08 +00:00
|
|
|
|
|
|
|
|
2018-04-01 18:15:35 +01:00
|
|
|
try:
|
|
|
|
list(gen())
|
|
|
|
except RuntimeError:
|
|
|
|
print("RuntimeError")
|
2018-04-10 05:39:51 +01:00
|
|
|
|
|
|
|
# recursion via an iterator over a generator
|
|
|
|
def gen2():
|
|
|
|
for x in gen2():
|
|
|
|
yield x
|
2020-03-23 02:26:08 +00:00
|
|
|
|
|
|
|
|
2018-04-10 05:39:51 +01:00
|
|
|
try:
|
|
|
|
next(gen2())
|
|
|
|
except RuntimeError:
|
|
|
|
print("RuntimeError")
|