-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebugly.py.save.1
More file actions
24 lines (20 loc) · 822 Bytes
/
Copy pathdebugly.py.save.1
File metadata and controls
24 lines (20 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from functools import wraps, partial
def debug(func=None,*, prefix=''):
#making the decorator callable within itself unlike providing another function
if func is None:
return partial(debug, prefix=prefix)
msg = prefix + func.__qualname__
#func as input
@wraps(func) #to copy meta data
def wrapper(*args, **kwargs):
print(msg_)#for classes names qualname is user
return func(*args, **kwargs)
return wrapper
#use of args for a decorator through creation under a environment function debugarg where the variables get stored and can be accessible to the
def debugarg(prefix = ''):
def debug(func):
@wraps(func)
def wrapper(*args, **kwargs):
print(func.__qualname__)#for classes names qualname is user
return func(*args, **kwargs)
return wrapper