MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / wrapper

Function wrapper

example_code/item_066.py:58–73  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

56
57 @wraps(func)
58 def wrapper(*args, **kwargs):
59 args_repr = repr(args)
60 kwargs_repr = repr(kwargs)
61 result = None
62 try:
63 result = func(*args, **kwargs)
64 return result
65 except Exception as e:
66 result = e
67 raise
68 finally:
69 print(
70 f"{func.__name__}"
71 f"({args_repr}, {kwargs_repr}) -> "
72 f"{result!r}"
73 )
74
75 wrapper.tracing = True
76 return wrapper

Callers

nothing calls this directly

Calls 1

funcFunction · 0.85

Tested by

no test coverage detected