How to do a Decorator Here?

2007-02-20 Thread Gregory Piñero
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

Re: How to do a Decorator Here?

2007-02-20 Thread Goldfish
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

Re: How to do a Decorator Here?

2007-02-20 Thread Gregory Piñero
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

Re: How to do a Decorator Here?

2007-02-20 Thread Matimus
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

Re: How to do a Decorator Here?

2007-02-20 Thread Michele Simionato
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