Python Decorators: Wonderful and beautiful syntactic sugar
avinashv.net
avinashv.net
Usually this is not a problem, but some people want to see the correct method signature when they look up the documentation (often auto-generated) for a function. And there are some programs that inspect the method signature and expect it to be correct.
http://www.phyast.pitt.edu/~micheles/python/documentation.ht... provides more details on this subject, as well as a library to mitigate this problem. I believe functools.wraps in python2.5 also solves this problem: http://docs.python.org/lib/module-functools.html
You're right though, I should have made that clearer.
They are very useful and insanely easy to use in python.
I concur about decorators being "insanely easy to use"--taking the memoization example I presented in the article; it's far, far simpler to tack on "@memoize" than to incorporate it into the flow of a function and risk losing clarity. I am sure TurboGears (and Django/Pylons) authors love that you can decorate something with @login_required (or equivalent) and have that method exposed to authentication.