class Adder(object):
def __init__(self, starting_sum=0.0):
self._current_sum = starting_sum
@property
def current_sum(self):
return self._current_sum
def __call__(self, value):
self._current_sum += value
functor = Adder(starting_sum=42)
print("After init", functor.current_sum)
functor(1)
print("After first call", functor.current_sum)
functor(3)
print("After second call", functor.current_sum)