-1
데코레이터에 값 목록을 전달하려고합니다. 데코레이터로 장식 된 모든 함수는 다른 값 목록을 전달합니다.데코레이터에 인수 전달
from decorator import decorator
def dec(func, *args):
// Do something with the *args - I guess *args contains the arguments
return func()
dec = decorator(dec)
@dec(['first_name', 'last_name'])
def my_function_1():
// Do whatever needs to be done
@dec(['email', 'zip'])
def my_function_2():
// Do whatever needs to be done
그러나,이 작동하지 않습니다 - 나는 decorator
파이썬 라이브러리 여기
을 사용하고하는 것은 내가하려고했던 것입니다. 오류가 발생합니다 - AttributeError: 'list' object has no attribute 'func_globals'
어떻게하면됩니까?
https://stackoverflow.com/questions/5929107/python-decorators-with-parameters –