class LengthAccumulator(object): def __init__(self): self.number = 1 def __neg__(self): self.number += 1 return self # otherwise I get a TypeError