It shouldn't be called a namespace unless the dominant access is via attributes.
On Thu, Aug 24, 2017 at 4:37 AM, Nick Coghlan <ncogh...@gmail.com> wrote: > On 24 August 2017 at 08:47, Ethan Furman <et...@stoneleaf.us> wrote: > > > > ContextVars is actually a different name for LogicalContext. So it would > > be: > > > > ExecutionContext = [ContextVars()[, ContextVars()[ ...]]] > > > > and you get the (thread.local similar) ContextVars by > > > > context_vars = sys.get_context_vars() # or whatever > > context_vars.verbose = ... > > Migrating a (variant of a) naming subthread from python-ideas over to > here, does the following sound plausible to anyone else?: > > ContextLocal - read/write access API (via get()/set() methods) > ContextLocalNamespace - active mapping that CL.get()/set() manipulates > ExecutionContext - current stack of context local namespaces > > Building a threading.local() style helper API would then look something > like: > > class ContextLocals: > def __init__(self, key_prefix): > self._key_prefix = key_prefix > > def __getattr__(self, attr): > debugging_name = "{}.{}".format(self._key_prefix, attr) > self.__dict__[attr] = new_local = > sys.new_context_local(debugging_name) > return new_local > > def __setattr__(self, attr, value): > getattr(self, attr).set(value) > > def __delattr__(self, attr): > getattr(self, attr).set(None) > > my_state = ContextLocals(__name__) > > Cheers, > Nick. > > -- > Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia > _______________________________________________ > 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/ > guido%40python.org > -- --Guido van Rossum (python.org/~guido)
_______________________________________________ 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