Hi, I try to define a (new-style) class who: - have a __slots__ defined to be strict attributes, - return None if the attribute is 'ok' but not set, or raise a 'normal' error if the attribute isn't in __slots__.
This code runs, but is it the good way? Thanks. class test(object): __slots__ = ['id'] def __getattr__(self, attr): if not attr in self.__slots__: raise AttributeError try: return self.attr except: return None -- http://mail.python.org/mailman/listinfo/python-list