PEP 342 (Coroutines via Enhanced Generators) added a throw() method to generator objects, which allows the caller to raise an exception inside the generato
throw()
This "answer" is more like a trivia.
We can (ab)use the generator's throw() to raise Exception inside a lambda, which does not otherwise support the raise statement.
raise
foo = lambda: (_ for _ in ()).throw(Exception('foobar'))
Quoted from https://stackoverflow.com/a/8294654/728675