CallCounter(limit) whose instances are callable: each call increments an internal count and returns 'ok' until limit is exceeded, after which it returns 'blocked'. __call__ turns objects into stateful functions — a common rate-limiter/middleware shape.c = CallCounter(2); [c(), c(), c()]
['ok', 'ok', 'blocked']
The third call crossed the limit.
def __call__(self): gives instances function syntax.
Compare the running count against the limit.