Decorator
Martin Blume
mblume at socha.net
Fri May 12 13:38:51 EDT 2006
"Sybren Stuvel" schrieb
> Martin Blume enlightened us with:
Don't know if I enlightened anybody ... :-)
> > Another question: Isn't decorating / wrapping
> > usually done at runtime, so that the @deco
> > notation is pretty useless (because you'd
> > have to change the original code)?
>
> Please explain why that would make the @deco
> notation pretty useless.
>
Well, if you're changing the original module, you
might as well insert the needed functionality in
the original function, no?
Or rename the original function, write a function
having this original name and calling from it the
original functionality?
Isn't the point of a decorator to change the
behavior externally, at runtime, possibly changing
it in different ways at different places at different
times?
So why this @deco notation? Can you apply it externally?
Meaning to
import module
first, then
@deco(module.func)
somewhere later?
Martin
More information about the Python-list
mailing list