[Python-ideas] Possible PEP 380 tweak
ncoghlan at gmail.com
Thu Oct 28 14:18:25 CEST 2010
On Thu, Oct 28, 2010 at 6:52 PM, Jacob Holm <jh at improva.dk> wrote:
> On 2010-10-28 00:52, Nick Coghlan wrote:
>> On Thu, Oct 28, 2010 at 6:22 AM, Jacob Holm <jh at improva.dk> wrote:
>>> Actually, AFAICT outer_broken will *not* give a RuntimeError on close()
>>> after next(). This is due to the special-casing of GeneratorExit in PEP
>>> 380. That special-casing is also the basis for both my suggested
>> Ah, you're quite right - I'd completely forgotten about the
>> GeneratorExit special-casing in the PEP 380 semantics, so I was
>> arguing from a faulty premise. With that error corrected, I can
>> happily withdraw my objection to idioms that convert GeneratorExit to
>> StopIteration (since any yield from expressions will reraise the
>> GeneratorExit in that case).
> Looks like we are still not on exactly the same page though... You seem
> to be arguing from the version at
> http://www.python.org/dev/peps/pep-0380, whereas I am looking at
> which is newer.
Ah, the comment earlier in the thread about the PEP not being up to
date with the last discussion makes more sense now...
Still, the revised expansion also does the right thing in the case
that was originally bothering me, and I agree with your suggested
tweak to that version. I've cc'ed Greg directly on this email - if he
wants, I can check in an updated version of the PEP to bring the
python.org version up to speed with the later discussions.
With that small change to the yield from expansion, as well as the
change to close to return the first argument to StopIteration (if any)
and None otherwise, I think PEP 380 will be in a much better position
to support user experimentation in this area.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas