Delegation in Python

Chris Angelico rosuav at
Sun Jan 25 00:43:33 CET 2015

On Sun, Jan 25, 2015 at 10:38 AM, Brian Gladman <noone at> wrote:
> On 24/01/2015 23:22, Chris Angelico wrote:
>> class RF(Fraction):
>>     def is_integer(self):
>>        return self.numerator % self.denominator == 0
> Thanks for your help on this.  I must admit that nowhere in a lot of
> searching did I find that delegation is achieved by doing nothing!

Hehe :) If you want a technical look at it, what you have is the
fundamental nature of subclassing: you derive from another class, and
your class is identical to that with certain exceptions (in your case,
an additional method). Python's way of handling that is called the
Method Resolution Order or MRO, and you can find info on it on the
web, eg:



More information about the Python-list mailing list