[issue4793] Glossary incorrectly describes a decorator as "merely syntactic sugar"

Lenard Lindstrom report at bugs.python.org
Wed Dec 31 20:44:27 CET 2008


Lenard Lindstrom <len-l at telus.net> added the comment:

It is distinct behavior. Without a decorator a new function is
immediately assigned to the identifier. Any previous reference is lost.
A decorator postpones assignment until the decorator returns. That
allows the decorator to access the previous object. I don't know of any
way to do the same thing with:

def foo():
   .....
foo = do_something(foo)

Here is part of a comp.lang.python thread discussing the possibility of
using a decorator for an overloaded function.

http://groups.google.com/group/comp.lang.python/browse_thread/thread/16a2e8b9d6705dfb/1cb0b358173daf06?lnk=gst&q=Lenard+Lindstrom+decorator#1cb0b358173daf06

Note that the decorator could create an overloaded function without any
extra variables. To do the equivalent in Python 2.3 a special attribute,
with a mangled name, was needed to store intermediate declarations.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4793>
_______________________________________


More information about the Python-bugs-list mailing list