def __setitem__(self, k, v): if k not in self._fields: raise errors.FieldError(k) setattr(self, k, v)
def __getitem__(self, k): if k not in self._fields: raise errors.FieldError(k) return getattr(self, k)