[Python-Dev] PEP 567 pre v3

Victor Stinner victor.stinner at gmail.com
Mon Jan 8 18:15:17 EST 2018


Hum, now I'm confused. I was probably confused by ContextVar.get()
differences with Context.get().

It's fine if it behaves with a dict.

Victor

Le 9 janv. 2018 12:02 AM, "Nathaniel Smith" <njs at pobox.com> a écrit :

> On Mon, Jan 8, 2018 at 2:35 PM, Victor Stinner <victor.stinner at gmail.com>
> wrote:
> > ctx[var] raises an exception but ctx.get(var) returns None in such case.
> My
> > point is just that Context.get() behaves differently than dict.get(). If
> > dict[key] raises, I expect that dict.get() raises too and that I have to
> > write explicitely dict.get(default=None).
>
> But that's not how dict.get works?
>
> In [1]: d = {}
>
> In [2]: print(d.get(1))
> None
>
> -n
>
> --
> Nathaniel J. Smith -- https://vorpus.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180109/4e0292ae/attachment-0001.html>


More information about the Python-Dev mailing list