Delegation in Python

Gary Herron gherron at digipen.edu
Sat Jan 24 18:47:56 EST 2015


On 01/24/2015 03:38 PM, Brian Gladman 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!
>
>     Brian

That's *not* "doing nothing".   And it's not even really "delegation".  
It's just sub-classing Fraction to add one new method and inherit all 
other methods.

Gary Herron


-- 
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418




More information about the Python-list mailing list