class A(object):

    def __setattr__(self, name, value):
        allowed = 'x',
if name in allowed:
    self.__dict__[name] = value
else:
    raise AttributeError('No attribute: %s' % name)
How to protect againt typos when setting value for class members?