def run_once(f):
 @functools.wraps(f)
 def wrapper():
  if (not wrapper.already_ran):
   f()
   wrapper.already_ran = True
 wrapper.already_ran = False
 return wrapper

def run_once ( f ) : @ functools . wraps ( f ) def wrapper ( ) : if ( not wrapper . already_ran ) : f ( ) wrapper . already_ran = True wrapper . already_ran = False return wrapper
a decorator to ensure the decorated function is only executed once .