Initial commit
This commit is contained in:
21
Solutions/7_2/logcall.py
Normal file
21
Solutions/7_2/logcall.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# logcall.py
|
||||
|
||||
from functools import wraps
|
||||
|
||||
def logformat(fmt):
|
||||
def logged(func):
|
||||
print('Adding logging to', func.__name__)
|
||||
@wraps(func)
|
||||
def wrapper(*args,**kwargs):
|
||||
print(fmt.format(func=func))
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
return logged
|
||||
|
||||
# Original no-argument @logged decorator defined in terms of the more
|
||||
# general @logformat decorator
|
||||
|
||||
logged = logformat('Calling {func.__name__}')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user