Answer the question
In order to leave comments, you need to log in
Why is decorator in python called at script start?
Found strange behavior in python3.5.
We write dumb code with a decorator:
def foo(f):
print("foo")
f()
@foo
def bar():
print("bar")
print (bar)
Answer the question
In order to leave comments, you need to log in
this is syntactic sugar in python and, in theory, should only replace this call with foo (bar) when calling the bar function
@foo
def bar():
print("bar")
def bar():
print("bar")
bar = foo(bar)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question