def __setattr__(self, name, value): if hasattr(self, name): self.__dict__[name] = value else: raise AttributeError('Invalid attribute "%s"' % name)