Delegation in Python

Gary Herron gherron at digipen.edu
Sun Jan 25 00:47:56 CET 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