Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #84519
| References | <FeCdnXdsTpunvlnJnZ2dnUVZ8judnZ2d@brightview.co.uk> <mailman.18106.1422141738.18130.python-list@python.org> <5ZKdnd6rbdZ3sVnJnZ2dnUVZ8mCdnZ2d@brightview.co.uk> |
|---|---|
| Date | 2015-01-25 10:43 +1100 |
| Subject | Re: Delegation in Python |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18109.1422143020.18130.python-list@python.org> (permalink) |
On Sun, Jan 25, 2015 at 10:38 AM, Brian Gladman <noone@nowhere.net> 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: http://python-history.blogspot.com/2010/06/method-resolution-order.html Enjoy! ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-24 22:57 +0000
Re: Delegation in Python Chris Angelico <rosuav@gmail.com> - 2015-01-25 10:22 +1100
Re: Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-24 23:38 +0000
Re: Delegation in Python Chris Angelico <rosuav@gmail.com> - 2015-01-25 10:43 +1100
Re: Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-25 00:18 +0000
Re: Delegation in Python Chris Angelico <rosuav@gmail.com> - 2015-01-25 11:28 +1100
Re: Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-25 07:49 +0000
Re: Delegation in Python Chris Angelico <rosuav@gmail.com> - 2015-01-25 19:07 +1100
Re: Delegation in Python Gary Herron <gherron@digipen.edu> - 2015-01-24 15:47 -0800
Re: Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-24 23:58 +0000
Re: Delegation in Python Gary Herron <gherron@digipen.edu> - 2015-01-24 15:41 -0800
Re: Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-24 23:52 +0000
Re: Delegation in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-24 23:59 +0000
Re: Delegation in Python Chris Angelico <rosuav@gmail.com> - 2015-01-25 11:07 +1100
Re: Delegation in Python Terry Reedy <tjreedy@udel.edu> - 2015-01-24 20:31 -0500
Re: Delegation in Python Brian Gladman <noone@nowhere.net> - 2015-01-25 07:43 +0000
csiph-web