[Python-Dev] PEP 550 v4
Yury Selivanov
yselivanov.ml at gmail.com
Wed Sep 6 19:53:06 EDT 2017
On Wed, Sep 6, 2017 at 1:39 PM, Koos Zevenhoven <k7hoven at gmail.com> wrote:
[..]
> Now this was of course a completely fictional example, and hopefully I
> didn't introduce any bugs or syntax errors other than the ones I described.
> I haven't seen code like this anywhere, but somehow we caught the problems
> anyway.
Thank you for the example, Koos. FWIW I agree it is a "completely
fictional example".
There are two ways how we can easily adapt PEP 550 to follow your semantics:
1. Set gen.__logical_context__ to None when it is being 'yield frommmed'
2. Merge gen.__logical_context__ with the outer LC when the generator
is iterated to the end.
But I still really dislike the examples you and Greg show to us. They
are not typical or real-world examples, they are showcases of ways to
abuse contexts.
I still think that giving Python programmers one strong rule: "context
mutation is always isolated in generators" makes it easier to reason
about the EC and write maintainable code.
Yury
More information about the Python-Dev
mailing list