yield in try/finally case
Random832
random832 at fastmail.com
Thu Mar 3 10:00:46 EST 2016
On Thu, Mar 3, 2016, at 06:52, 刘琦帆 wrote:
> 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/
I'm not sure I understand this reasoning. Why not simply execute it in
__del__ if it hasn't been reached until then? AIUI that is what C# does.
More information about the Python-list
mailing list