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

Function fixed_log

example_code/item_086.py:220–235  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

218
219print("Example 8")
220def fixed_log(func):
221 @functools.wraps(func)
222 def wrapper(*args, **kwargs):
223 try:
224 result = func(*args, **kwargs)
225 except BaseException as e: # Fixed
226 result = e
227 raise
228 finally:
229 print(
230 f"Called {func.__name__}"
231 f"(*{args!r}, **{kwargs!r}) "
232 f"got {result!r}"
233 )
234
235 return wrapper
236
237
238print("Example 9")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected