Re: Classes derived from dict and eval

2005-09-22 Thread Jeremy Sanders
On Tue, 20 Sep 2005 13:59:50 -0700, Robert Kern wrote: > globals needs to be a real dictionary. The implementation uses the C > API, it doesn't use the overridden __getitem__. The locals argument, > apparently can be some other kind of mapping. It seems that on Python 2.3 then neither globals or

Re: Classes derived from dict and eval

2005-09-21 Thread Kent Johnson
Jeremy Sanders wrote: > Hi - > > I'm trying to subclass a dict which is used as the globals environment of > an eval expression. For instance: > > class Foo(dict): > def __init__(self): > self.update(globals()) > self['val'] = 42 > > def __getitem__(self,

Re: Classes derived from dict and eval

2005-09-20 Thread Robert Kern
Jeremy Sanders wrote: > Hi - > > I'm trying to subclass a dict which is used as the globals environment of > an eval expression. For instance: > > class Foo(dict): > def __init__(self): > self.update(globals()) > self['val'] = 42 > > def __getitem__(self,

Classes derived from dict and eval

2005-09-20 Thread Jeremy Sanders
Hi - I'm trying to subclass a dict which is used as the globals environment of an eval expression. For instance: class Foo(dict): def __init__(self): self.update(globals()) self['val'] = 42 def __getitem__(self, item): # this doesn't get called fr