[Python-Dev] PEP 550 v4

Yury Selivanov yselivanov.ml at gmail.com
Sat Aug 26 13:19:55 EDT 2017


On Sat, Aug 26, 2017 at 1:10 PM, David Mertz <mertz at gnosis.cx> wrote:
> Would it be possible/desirable to make the default a unique string value
> like a UUID or a stringified counter?

Sure, or we could just use the id of ContextVar.

In the end, when we want to introspect the EC while debugging, we
would see something like this:

{
   ContextVar(name='518CDD4F-D676-408F-B968-E144F792D055'): 42,
   ContextVar(name='decimal_context'): DecimalContext(precision=2),
   ContextVar(name='7A44D3BE-F7A1-40B7-BE51-7DFFA7E0E02F'): 'spam'
}

That's why I think it's easier to force users always specify the name:

    my_var = sys.new_context_var('my_var')

This is similar to namedtuples, and nobody really complains about them.

Yury


More information about the Python-Dev mailing list