Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 47)
47.
How does the generator.throw(RuntimeError, "message") method affect a running generator?
It raises a custom exception inside the generator
It forcibly terminates the generator
It has no effect on the running generator
It restarts the generator from the beginning
Answer: Option
Explanation:
generator.throw(RuntimeError, "message") raises a custom exception of type RuntimeError with the specified message inside the generator.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.