Re: execute a function before and after any method of a parent class

2008-10-07 Thread Gabriel Genellina
En Tue, 07 Oct 2008 10:34:44 -0300, Michele Simionato <[EMAIL PROTECTED]> escribió: On Oct 3, 9:23 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: Ok, but then you have to explicitely decorate every method. To avoid this,   you may use a metaclass; this article by Michael Foord explains

Re: execute a function before and after any method of a parent class

2008-10-07 Thread Michele Simionato
On Oct 3, 9:23 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > Ok, but then you have to explicitely decorate every method. To avoid this,   > you may use a metaclass; this article by Michael Foord explains > how:http://www.voidspace.org.uk/python/articles/metaclasses.shtml#a-metho... Since

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Steven D'Aprano
On Fri, 03 Oct 2008 16:03:22 +0200, TP wrote: > Hi everybody, > > I would like to be able to specialize an existing class A, so as to > obtain a class B(A), with all methods of B being the methods of A > preceded by a special method of B called _before_any_method_of_A( self > ), and followed by a

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Terry Reedy
Gabriel Genellina wrote: En Fri, 03 Oct 2008 11:03:22 -0300, TP <[EMAIL PROTECTED]> escribió: I would like to be able to specialize an existing class A, so as to obtain a class B(A), with all methods of B being the methods of A preceded by a special method of B called _before_any_method_of_A(

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Gabriel Genellina
En Fri, 03 Oct 2008 11:03:22 -0300, TP <[EMAIL PROTECTED]> escribió: I would like to be able to specialize an existing class A, so as to obtain a class B(A), with all methods of B being the methods of A preceded by a special method of B called _before_any_method_of_A( self ), and followed

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Aaron "Castironpi" Brady
On Oct 3, 9:03 am, TP <[EMAIL PROTECTED]> wrote: > Hi everybody, > > I would like to be able to specialize an existing class A, so as to obtain a > class B(A), with all methods of B being the methods of A preceded by a > special method of B called _before_any_method_of_A( self ), and followed by >

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Almar Klein
Maybe you can use __getattribute__. I tried it, but got stuck trying to let __getattribute__ work normal without calling itself. class A(object): def foo(self): print "hi" class B(A): def __getattribute__(self,name): try: fun = A.__dict__[name] except K

execute a function before and after any method of a parent class

2008-10-03 Thread TP
Hi everybody, I would like to be able to specialize an existing class A, so as to obtain a class B(A), with all methods of B being the methods of A preceded by a special method of B called _before_any_method_of_A( self ), and followed by a special method of B called _after_any_method_of_A( self ).