<div dir="auto"><div class="gmail_extra" dir="auto"><div class="gmail_quote">On Oct 7, 2017 12:20, "Koos Zevenhoven" <<a href="mailto:k7hoven@gmail.com">k7hoven@gmail.com</a>> wrote:<blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="elided-text"><div><br></div></div><div><div class="gmail_default" style="font-family:monospace,monospace">​Unfortunately, we actually need a third kind of generator semantics, something like this:</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">@​contextvars.caller_context</div><div class="gmail_default" style="font-family:monospace,monospace">def genfunc():</div><div class="gmail_default" style="font-family:monospace,monospace">    assert cvar.value is the_value</div><div class="gmail_default" style="font-family:monospace,monospace">    yield</div><div class="gmail_default" style="font-family:monospace,monospace">    assert cvar.value is the_value</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">with cvar.assign(the_value):</div><div class="gmail_default" style="font-family:monospace,monospace">    gen = genfunc()</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">next(gen)</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">with cvar.assign(1234567890):</div><div class="gmail_default" style="font-family:monospace,monospace">    try:</div><div class="gmail_default" style="font-family:monospace,monospace">        next(gen)</div><div class="gmail_default" style="font-family:monospace,monospace">    except StopIteration:</div><div class="gmail_default" style="font-family:monospace,monospace">        pass</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Nick, Yury and I (and Nathaniel, Guido, Jim, ...?) somehow just narrowly missed the reasons for this in discussions related to PEP 550. Perhaps because we had mostly been looking at it from an async angle.</div></div></div></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">That's certainly a semantics that one can write down (and it's what the very first version of PEP 550 did), but why do you say it's needed? What are these reasons that were missed? Do you have a use case?</div><div dir="auto"><br></div><div dir="auto">-n</div></div>