[Python-Dev] PEP 343 - Abstract Block Redux
Steven Bethard
steven.bethard at gmail.com
Mon May 16 07:53:52 CEST 2005
On 5/15/05, Nick Coghlan <ncoghlan at gmail.com> wrote:
> http://members.iinet.net.au/~ncoghlan/public/pep-3XX.html
In reading over PEP 3XX again, it struck me that I'd been having a
really hard time grasping exactly when I needed to use the
"needs_finish" decorator. Am I right in saying that I should use the
"needs_finish" decorator every time I have a "yield" inside a
with-statement or a try/finally? Are there other situations where I
might need the "needs_finish" decorator?
If it's true that I need the "needs_finish" decorator every time I
have a "yield" inside a with-statement or a try/finally, I'd be
inclined to do this automatically. That is, since a yield inside a
with-statement or try/finally can be determined lexically (heck, we do
it now to disallow it), generators that have such code should be
automatically wrapped with the "needs_finish" decorator, i.e. they
should automatically acquire a __finish__ method.
If I've misunderstood, and there are other situations when
"needs_finish" is required, it'd be nice to see some more examples.
STeVe
--
You can wordify anything if you just verb it.
--- Bucky Katt, Get Fuzzy
More information about the Python-Dev
mailing list