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

Function wrapper

example_code/item_086.py:176–187  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

174def log(func):
175 @functools.wraps(func)
176 def wrapper(*args, **kwargs):
177 try:
178 result = func(*args, **kwargs)
179 except Exception as e:
180 result = e
181 raise
182 finally:
183 print(
184 f"Called {func.__name__}"
185 f"(*{args!r}, **{kwargs!r}) "
186 f"got {result!r}"
187 )
188
189 return wrapper
190

Callers

nothing calls this directly

Calls 1

funcFunction · 0.85

Tested by

no test coverage detected