Message78643
http://www.python.org/doc/2.6/glossary.html
The decorator entry in the Python 2.6 documentation incorrectly
describes a decorator as "merely syntactic sugar". It is not, as this
example shows:
>>> def decorator(f):
f.prev = globals()[f.__name__]
return f
>>> func = 0
>>> def func():
pass
>>> func = decorator(func)
>>> func.prev
<function func at 0x00C748F0>
>>> func = 0
>>> @decorator
def func():
pass
>>> func.prev
0
This distinction could be useful in building multi-methods, for example. |
|
Date |
User |
Action |
Args |
2008-12-31 18:59:36 | kermode | set | recipients:
+ kermode, georg.brandl |
2008-12-31 18:59:36 | kermode | set | messageid: <1230749976.35.0.878652242005.issue4793@psf.upfronthosting.co.za> |
2008-12-31 18:59:34 | kermode | link | issue4793 messages |
2008-12-31 18:59:34 | kermode | create | |
|