def flag_calls(func):
 if hasattr(func, 'called'):
  return func
 def wrapper(*args, **kw):
  wrapper.called = False
  out = func(*args, **kw)
  wrapper.called = True
  return out
 wrapper.called = False
 wrapper.__doc__ = func.__doc__
 return wrapper

def flag_calls ( func ) : if hasattr ( func , 'called' ) : return func def wrapper ( * args , ** kw ) : wrapper . called = False out = func ( * args , ** kw ) wrapper . called = True return out wrapper . called = False wrapper . __doc__ = func . __doc__ return wrapper
wrap a function to detect and flag when it gets called .