MCPcopy Create free account
hub / github.com/dabeaz-course/practical-python / wrapper

Function wrapper

Solutions/8_1/timethis.py:6–12  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

4
5def timethis(func):
6 def wrapper(*args, **kwargs):
7 start = time.time()
8 try:
9 return func(*args,**kwargs)
10 finally:
11 end = time.time()
12 print("%s.%s : %f" % (func.__module__,func.__name__,end-start))
13 return wrapper
14
15if __name__ == '__main__':

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected