def __set__(self, instance, value):
    setattr(instance, self.name, value)


class C(object):
    __slots__ = ['_a']
a = MyDescriptor('_a')

def __init__(self, val):
    self.a = val
foo = C(1)
print(foo.a)
foo.a = 2
print(foo.a)
Using Python descriptors with slots