Message78647
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. |
|
Date |
User |
Action |
Args |
2008-12-31 19:44:27 | kermode | set | recipients:
+ kermode, georg.brandl, gpolo |
2008-12-31 19:44:27 | kermode | set | messageid: <1230752667.11.0.970740513714.issue4793@psf.upfronthosting.co.za> |
2008-12-31 19:44:26 | kermode | link | issue4793 messages |
2008-12-31 19:44:25 | kermode | create | |
|