I think we can expose the default property. If it's not set we can return MISSING.
Yury
Sent from my iPhone
> On Jan 3, 2018, at 1:04 PM, Victor Stinner <victor.stinner at gmail.com> wrote:
>> Le 3 janv. 2018 06:38, "Guido van Rossum" <guido at python.org> a écrit :
> But is there a common use case? For var.get() I'd rather just pass the default or catch the exception if the flow is different. Using ctx[var] is rare (mostly for printing contexts, and perhaps for explaining var.get()).
>> I don't think that it would be a common use case. Maybe we don't need is_set(), I'm fine with catching an exception.
>> But for introspection at least, it would help to expose the default as a read-only attribute, no?
>> Another example of a mapping with default value:
>>https://docs.python.org/dev/library/collections.html#collections.defaultdict>> And defaultdict has a default_factory attribute. The difference here is that default_factory is mandatory. ContextVar would be simpler if the default would be mandatory as well :-)
>> Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180103/d3a2c6fa/attachment.html>