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