Using non-dict namespaces in functions
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sat Mar 17 21:52:25 EDT 2012
On Sat, 17 Mar 2012 11:42:49 -0700, Eric Snow wrote:
> On Sat, Mar 17, 2012 at 4:18 AM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> Note that it is important for my purposes that MockChainMap does not
>> inherit from dict.
>
> Care to elaborate?
I want to use collections.ChainMap, or something very like it, and I
don't want to be forced into an unnatural is-a relationship with dict if
I don't have to.
[...]
> Regardless, you could also implement __call__() on a function look-alike
> class to get what you're after. It may not be as performant though.
I don't think that can work, because __call__ itself is a function, and I
would need to change *its* globals. Which brings me back exactly where I
started, trying to change globals in a function to a non-dict.
--
Steven
More information about the Python-list
mailing list