def logger filename def decorator func def wrapped args kwargs result

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
def logger(filename):
def decorator(func):
def wrapped(*args, **kwargs):
result = func(*args, **kwargs)
return result
return wrapped
return decorator
@logger('new_log.txt')
def summator(num_list):
return sum(num_list)
print('summator: {}'.format(summator([1, 2, 3, 4, 5, 6])))
print(logger.__name__)
print(logger('new_log.txt').__name__)
print(logger('new_log.txt')().__name__)
print(summator.__name__)
print(type(summator([1, 2, 3, 4, 5, 6])))