Showing content from http://mail.python.org/pipermail/python-dev/attachments/20180102/fa0a3721/attachment.html below:
<div dir="ltr"><div>Oh, the "Specification" section in the PEP is too brief on several of these subjects. It doesn't really specify what var.get() does if the value is not set, nor does it even mention var.get(<default>) except in the code examples for var.reset(). It's also subtle that ctx[var] returns the default (if there is one). I suppose it will raise if there isn't one -- resulting in the somewhat surprising behavior where `var in ctx` may be true but `ctx[var]` may raise. And what does it raise? (All these questions are answered by the code, but they should be clearly stated in the PEP.)<br><br></div>I would really like to invite more people to review this PEP! I expect I'll be accepting it in the next two weeks, but it needs to go through more rigorous review.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 28, 2017 at 4:48 PM, Victor Stinner <span dir="ltr"><<a href="mailto:victor.stinner@gmail.com" target="_blank">victor.stinner@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><span class=""><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" target="_blank">njs@pobox.com</a>> a écrit :<br type="attribution"><blockquote class="m_7156669668159093585quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_7156669668159093585quoted-text">On Thu, Dec 28, 2017 at 1:51 AM, Victor Stinner<br>
<<a href="mailto:victor.stinner@gmail.com" target="_blank">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></span><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><span class="HOEnZb"><font color="#888888"><div dir="auto"><br></div><div dir="auto">Victor</div><div class="gmail_extra" dir="auto"></div></font></span></div>
<br>______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>guido%40python.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4