[PEAK] Inheritance and @when from PEAK-rules

Athanasios Anastasiou athanasios.anastasiou at plymouth.ac.uk
Tue Jul 17 05:40:07 EDT 2012


Dear Phillipe

Thank you very much for your help, i vaguely remember trying just 
BaseClass.methodName before but don't remember why i did not keep it.

Anyway, BaseClass.methodName.im_func works fine.

All the best
Athanasios Anastasiou



On 16/07/2012 19:07, PJ Eby wrote:
> On Mon, Jul 16, 2012 at 12:56 PM, Athanasios Anastasiou
> <athanasios.anastasiou at plymouth.ac.uk> wrote:
>> Hello everyone
>>
>> I have been using PEAK-rules with functions but i came across some strange
>> behaviour when it came to using it with classes and inherited methods.
>>
>> The problem (in one line) is that i find it difficult to get @when to call
>> the "right" (overriden) function.
>
> If you want to use generic functions as methods, you must use
> @when(BaseClass.methodName.im_func) when defining overrides in a
> subclass.  (Otherwise, your new method either will be called in place
> of the generic function (if named the same) or it will not be called
> at all (if it has a different name).
>
> And, if you want that method to be able to call previous methods, use
> the next_method machinery, not super().  (Otherwise, you will simply
> call the same generic function a second time!)
>



More information about the PEAK mailing list