Skip to content

Instantly share code, notes, and snippets.

@superbobry
Created November 11, 2014 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superbobry/44276d49244c381be649 to your computer and use it in GitHub Desktop.
Save superbobry/44276d49244c381be649 to your computer and use it in GitHub Desktop.
Python generators and 'throw'
>>> def g():
... yield 42
...
>>> gen = g()
>>> next(gen)
42
>>> gen.throw(RuntimeError)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in g
RuntimeError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment