jeff at ccvcorp.com
Mon Aug 9 22:49:40 CEST 2004
Dan Bishop wrote:
>"Colin J. Williams" <cjw at sympatico.ca> wrote in message news:<%A8Rc.50217$Vm1.1280580 at news20.bellglobal.com>...
>>Christopher T. King suggested that "we're trying to kill too many birds
>>with one stone".
>>He goes on to suggest three needs which decorators serve. Are these the
>>only purposes which are envisaged for decorators?
>If I understand correctly, they'd be useful for anything where you'd
>now use the syntax
>function = decorator(function)
Many of the uses I'm seeing proposed for decorators would fit better
into the current syntax:
def func( ... )
In other words, they're not specifically changing the behavior of the
function, but they are using the (name and/or address of the) function
in some other context. The modification of the function (or method)
itself is an unnecessary side effect.
Whether this distinction matters is obviously a purely aesthetic matter,
since obviously the decorator can rebind the name to the original
function object instead of a wrapping-function object. But still, it
does suggest that this concept is indeed being put to multiple
More information about the Python-list