Need some decorator help.
I have a class. And I want to add behavior to one of this class's
methods to be run before the class runs the actual method. Is this
what decorators are for?
So the class I want to work with is string.Template
Let's say I have this:
from string import Template
On Feb 20, 8:20 pm, Gregory Piñero [EMAIL PROTECTED] wrote:
Need some decorator help.
I have a class. And I want to add behavior to one of this class's
methods to be run before the class runs the actual method. Is this
what decorators are for?
So the class I want to work with is
On 2/20/07, Tim Mitchell [EMAIL PROTECTED] wrote:
Hi Greg,
Decorators would work fine if the the class you were working with was
_yours_ (ie. you wrote it), the problem here is that string.Template is
someone else's class that you're trying to modify.
Here's how a decorator would work
On Feb 20, 12:20 pm, Gregory Piñero [EMAIL PROTECTED] wrote:
Need some decorator help.
I have a class. And I want to add behavior to one of this class's
methods to be run before the class runs the actual method. Is this
what decorators are for?
So the class I want to work with is
On Feb 20, 9:20 pm, Gregory Piñero [EMAIL PROTECTED] wrote:
Or is this not what decorators do? I'm trying to avoid subclassing if I can.
Your problem, overriding a method, is what inheritance was made for.
If you want
to know more about decorators, see Dr Mertz's last article