<div dir="auto"><br><div class="gmail_extra" dir="auto"><br><div class="gmail_quote">Le 3 janv. 2018 06:34, "Guido van Rossum" <<a href="mailto:guido@python.org">guido@python.org</a>> a écrit :<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">I think the issue here is a bit different than Yury's response suggests -- it's more like how a variable containing an immutable value (e.g. a string) can be modified, e.g.<br></div><div class="gmail_quote"><div><br></div><div>x = 'a'<br></div><div>x += 'b'<br></div><div><br></div><div>In our case the *variable* is the current thread state (in particular the slot therein that holds the context -- this slot can be modified by the C API). The *value* is the Context object. It is a collections.Mapping (or typing.Mapping) which does not have mutating methods. (The mutable type is called MutableMapping.)</div></div></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">I can see a parallel with a Python namespace, like globals and locals arguments of exec():</div><div dir="auto"><br></div><div dir="auto">ns = globals().copy()  # ctx = copy_context()</div><div dir="auto">exec("x = 'a'", ns, ns)  # ctx.run(...)</div><div dir="auto">ns['x'] += 'b'  # Context ???</div><div dir="auto">print(ns ['x'])  # print(ctx[x])</div><div dir="auto"><br></div><div class="gmail_extra" dir="auto"><div class="gmail_quote"><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>The *reason* for doing it this way is that Yury doesn't want Context to implement __delitem__, since it would complicate the specification of chained lookups by a future PEP, and chained lookups look to be the best option to extend the Context machinery for generators.</div></div></div></div></blockquote></div></div><div class="gmail_extra" dir="auto"><br></div><div class="gmail_extra" dir="auto">Again, why not just raise an exception on "del ctx[var]"?</div><div class="gmail_extra" dir="auto"><br></div><div class="gmail_extra" dir="auto">Victor</div></div>