We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
from functools import wraps def decorator_name(f): @wraps(f) def decorated(*args, **kwargs): if not can_run: return "함수는 실행되지 않습니다." return f(*args, **kwargs) return decorated @decorator_name def func(): print "함수가 실행 중입니다." can_run = True print(func()) #output: 함수가 실행 중입니다
위의 소스처럼 can_run이 True인 상태에서 print(func())을 실행하면 실행 결과는
can_run
True
print(func())
함수가 실행 중입니다. None
으로 None까지 같이 출력됩니다. def decorated()의 return이 f()이고, f에 해당하는 func()는 return값이 없기 때문에요. 차라리 func()을
def decorated()
f()
f
func()
@decorator_name def func(): return "함수가 실행 중입니다."
으로 하는 게 더 낫지 않을까요?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
위의 소스처럼
can_run
이True
인 상태에서print(func())
을 실행하면 실행 결과는으로 None까지 같이 출력됩니다.
def decorated()
의 return이f()
이고,f
에 해당하는func()
는 return값이 없기 때문에요.차라리
func()
을으로 하는 게 더 낫지 않을까요?
The text was updated successfully, but these errors were encountered: