Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103966
| From | Random832 <random832@fastmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: yield in try/finally case |
| Date | 2016-03-03 10:00 -0500 |
| Message-ID | <mailman.149.1457017249.20602.python-list@python.org> (permalink) |
| References | <84965b86-819b-4924-bca9-e82eed040606@googlegroups.com> |
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
yield in try/finally case 刘琦帆 <lqf.txx@gmail.com> - 2016-03-03 03:52 -0800
Re: yield in try/finally case Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2016-03-03 12:13 +0000
Re: yield in try/finally case 刘琦帆 <lqf.txx@gmail.com> - 2016-03-03 04:52 -0800
Re: yield in try/finally case Peter Otten <__peter__@web.de> - 2016-03-03 14:47 +0100
Re: yield in try/finally case Random832 <random832@fastmail.com> - 2016-03-03 10:12 -0500
Re: yield in try/finally case Peter Otten <__peter__@web.de> - 2016-03-03 17:20 +0100
Re: yield in try/finally case Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2016-03-03 16:24 +0000
Re: yield in try/finally case Random832 <random832@fastmail.com> - 2016-03-03 10:00 -0500
Re: yield in try/finally case Steven D'Aprano <steve@pearwood.info> - 2016-03-04 02:57 +1100
csiph-web