gen_yield_from_executing.py 253 B

123456789101112131415
  1. # yielding from an already executing generator is not allowed
  2. def f():
  3. yield 1
  4. # g here is already executing so this will raise an exception
  5. yield from g
  6. g = f()
  7. print(next(g))
  8. try:
  9. next(g)
  10. except ValueError:
  11. print('ValueError')