According to this answer Change attribute after each object calling, I thought that call method should do something to its instance everytime its called. I'm trying to use this in my code but I'm wrong somewhere.
class switcher():
current_index = -1
def __call__(self):
self.current_index +=1
sw = switcher()
print sw.current_index
print sw.current_index
output: -1
output: -1
I think that it should return this:
output: 0
output: 1
because it increments the current_index
value everytime the sw instance is called.
Obviously I'm wrong, could you tell me where is the problem please?