On Wednesday 04 June 2008 07:41:49 Marilyn Davis wrote: > On Tue, June 3, 2008 10:16 pm, Alan Gauld wrote: > > "Laureano Arcanio" <[EMAIL PROTECTED]> wrote > > > >> Is there any way to intercept calls to methods ? like the > >> __setattribute__ > >> medthod does ? > > > > There are several variations on how to do that kind of thing. > > Can you give us some more background on what you are > > trying to achieve that makes you need to do that? > > Great question, Alan. But, whatever the answer, I'd like to see the > variations listed, if you have time.
Well, let's start the ball rolling then. __getattribute__ __getattr__ Metaclasses decorators properties __init__ The basic working is that you've got a function, and that get's wrapped. In the "normal case", the function is a (__get__ only) property, and this __get__ is what makes Bound/Unbound methods out of a function object. (you can check it out, SomeClass.method versus SomeClass.__dict__["method"] versus SomeClass().method) Now the above listing is basically a list of points were you can effect a change of behaviour. One of the classical uses for that messy business is usually some kind of automatically constructed "proxy" class. (Proxy is rather general, e.g. RPC, or ORM classes come to mind) Andreas
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
