2 ms·
They're applied at parse-time, and they completely mask the def that they are applied to. Yes, the function being used as a decorator could just as easily be c
by blasdel 17y ago
They're applied at parse-time, and they completely mask the def that they are applied to.
Yes, the function being used as a decorator could just as easily be called at runtime, and that does break the similarity to macros somewhat.
- njharman 17y agoOnly decorator syntax happens somewhere around parse-time (which I call import time, but meh). > completely mask the def that they are applied to. @decorator reassign to the name of the def. But if there are other refs to that def they do not change and are not "masked". It is no different than assignment. You know that these two are identical, right? @foo def bar(): pass def bar(): pass bar = foo(bar) Also this is a perfectly valid decorater that doesn't mask the original func def deco(func): # do something terrible clever here return func decorator syntax != decorators is my main point. But by conflating the two I can begin to understand your statement.