<div dir="auto"><div class="gmail_extra" dir="auto"><div class="gmail_quote">NLe 28 déc. 2017 11:20 AM, "Nathaniel Smith" <<a href="mailto:njs@pobox.com">njs@pobox.com</a>> a écrit :<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="quoted-text">On Thu, Dec 28, 2017 at 1:51 AM, Victor Stinner<br>
<<a href="mailto:victor.stinner@gmail.com">victor.stinner@gmail.com</a>> wrote:<br>
> var = ContextVar('var', default=42)<br>
><br>
> and:<br>
><br>
> var = ContextVar('var')<br>
> var.set (42)<br>
><br>
> behaves the same, no?<br>
<br>
</div>No, they're different. The second sets the value in the current<br>
context. The first sets the value in all contexts that currently<br>
exist, and all empty contexts created in the future.</blockquote></div></div><div dir="auto"><br></div><div dir="auto">Oh, that's an important information. In this case, "default" is the best name.</div><div dir="auto"><br></div><div dir="auto">The PEP may be more explicit about the effect on all contexts. Proposition of documentation:</div><div dir="auto"><br></div><div dir="auto">"The optional *default* parameter is the default value in all contexts. If <span style="font-family:sans-serif">the variable is not set in the current context, it</span> is returned by <span style="font-family:sans-serif">by context[var_name] and by var.g</span>et(), when get() is called without the default parameter."</div><div dir="auto"><br></div><div dir="auto">Victor</div><div class="gmail_extra" dir="auto"></div></div>