def runs_last(func):
 def Wrapper():
  calls = func.num_host_calls
  if (calls >= (len(env.hosts) - 1)):
   return func()
  else:
   func.num_host_calls = (calls + 1)
   return None
 setattr(func, 'num_host_calls', 0)
 return Wrapper

def runs_last ( func ) : def Wrapper ( ) : calls = func . num_host_calls if ( calls >= ( len ( env . hosts ) - 1 ) ) : return func ( ) else : func . num_host_calls = ( calls + 1 ) return None setattr ( func , 'num_host_calls' , 0 ) return Wrapper
decorator to run a function only on the last invocation .