class MyClass(object):

    def __init__(self, x):
        self._x = x

def get_x(self):
    print('in get_x: do something here')
return self._x

def set_x(self, x):
    print('in set_x: do something')
self._x = x
x = property(get_x, set_x)
if __name__ == '__main__':
    m = MyClass(10)
print('m.x is %s' % m.x)
m.x = 5
print('m.x is %s' % m.x)
Python: How to make object attribute refer call a method