MCPcopy Create free account
hub / github.com/dabeaz-course/python-mastery / logformat

Function logformat

Solutions/7_2/logcall.py:5–13  ·  view source on GitHub ↗
(fmt)

Source from the content-addressed store, hash-verified

3from functools import wraps
4
5def logformat(fmt):
6 def logged(func):
7 print('Adding logging to', func.__name__)
8 @wraps(func)
9 def wrapper(*args,**kwargs):
10 print(fmt.format(func=func))
11 return func(*args, **kwargs)
12 return wrapper
13 return logged
14
15# Original no-argument @logged decorator defined in terms of the more
16# general @logformat decorator

Callers 1

logcall.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected