import datetime
import time
def my_timer(original_function):
import time
def wrapper(*args, **kwargs):
t1 = time.time()
result = original_function(*args, **kwargs)
t2 = time.time() - t1
print(f'{original_function.__name__} 함수가 실행된 총 시간: {t2}초')
return result
return wrapper
@my_timer
def display_info(name, age):
time.sleep(1)
print(f'display_info({name}, {age}) 함수가 실행됐습니다.')
def outer_func(calc:int):
def inner_func(num:int):
if calc == 1: # calc는 free variable
print(f'{num} + {num} = {num*2}')
return inner_func
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
display_info('John', 25)
a = outer_func(1) # closure
a(3)
# See PyCharm help at https://www.jetbrains.com/help/pycharm/