James Stroud wrote: > Here it goes with a little less overhead: > > > py> class namespace: > ... def __init__(self, adict): > ... self.__dict__.update(adict) > ... > py> n = namespace({'bob':1, 'carol':2, 'ted':3, 'alice':4}) > py> n.bob > 1 > py> n.ted > 3 > > James
How about... class namespace(dict): __getattr__ = dict.__getitem__ __setattr__ = dict.__setitem__ __delattr__ = dict.__delitem__ This seems to work, and eliminates the indirect method calls. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list