-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecorator.py
More file actions
37 lines (28 loc) · 902 Bytes
/
decorator.py
File metadata and controls
37 lines (28 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
from functools import wraps
def decorator_func(original_func):
# @wraps(original_func)
def wrapper_func(*args,**kwargs):
print ('call function %s()' % original_func.__name__)
return original_func(*args,**kwargs)
return wrapper_func
def decorator_func2(original_func):
# @wraps(original_func)
def wrapper_func(*args,**kwargs):
print ('call function %s() again' % original_func.__name__)
return original_func(*args,**kwargs)
return wrapper_func
#@decorator_func
#@decorator_func equals to
#display=decorator_func(display)
def display():
print('display function ran')
#display()
#@decorator_func2
#@decorator_func
def display_info(name,age):
print('name is %s and age is %s' % (name,age))
display_info=decorator_func(display_info)
display_info('Dan',31)
#print(display_info.__name__)
#display_info('Dan',31)