GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • [Python-Dev] PEP 567 v2
  • [Python-Dev] PEP 567 v2
  • [ date ]
  • [ thread ]
  • [ subject ]
  • [ author ]

This view

  • Original page
  • New address

GeezerVison is showing mail.python.org — [Python-Dev] PEP 567 v2

[Python-Dev] PEP 567 v2

Victor Stinner victor.stinner at gmail.com
Thu Dec 28 18:48:00 EST 2017

  • Previous message (by thread): [Python-Dev] PEP 567 v2
  • Next message (by thread): [Python-Dev] PEP 567 v2
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

NLe 28 déc. 2017 11:20 AM, "Nathaniel Smith" <njs at pobox.com> a écrit :

On Thu, Dec 28, 2017 at 1:51 AM, Victor Stinner
<victor.stinner at gmail.com> wrote:
> var = ContextVar('var', default=42)
>
> and:
>
> var = ContextVar('var')
> var.set (42)
>
> behaves the same, no?

No, they're different. The second sets the value in the current
context. The first sets the value in all contexts that currently
exist, and all empty contexts created in the future.


Oh, that's an important information. In this case, "default" is the best
name.

The PEP may be more explicit about the effect on all contexts. Proposition
of documentation:

"The optional *default* parameter is the default value in all contexts. If the
variable is not set in the current context, it is returned by by
context[var_name] and by var.get(), when get() is called without the
default parameter."

Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171229/329a0b72/attachment.html>

  • Previous message (by thread): [Python-Dev] PEP 567 v2
  • Next message (by thread): [Python-Dev] PEP 567 v2
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

More information about the Python-Dev mailing list
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.