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.stin...@gmail.com> wrote: > > Le 3 janv. 2018 06:38, "Guido van Rossum" <gu...@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
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com