yield in try/finally case

刘琦帆 lqf.txx at gmail.com
Thu Mar 3 06:52:11 EST 2016


I have just saw PEP 255, and it says that 

"A yield statement is not allowed in the try clause of a try/finally construct.  The difficulty is that there's no guarantee the generator will ever be resumed, hence no guarantee that the finally block will ever get executed; that's too much a violation of finally's purpose to bear." from https://www.python.org/dev/peps/pep-0255/

But, meanwhile, the code showed on that page use yield in a try/finally case.
It really puzzles me. Is there anything wrong?



More information about the Python-list mailing list