import UserDict class Rec(UserDict.DictMixin): "Dict like class allowing a.x instead of a['x']" def __init__(self, dict=None, **kwargs): self.__dict__ = {} if dict is not None: self.update(dict) if len(kwargs): self.update(kwargs) def __setitem__(self, name, value): setattr(self, name, value) def __getitem__(self, name): return getattr(self,name,None) def __getattr__(self,key): return None def has_key(self,key): return True if self.__dict__.has_key(key) else False def keys(self): return list(self.__dict__) def __len__(self): return len(self.__dict__) def __nonzero__(self): return len(self.__dict__)