On Sun, Jan 25, 2015 at 11:18 AM, Brian Gladman <no...@nowhere.net> wrote: > Is there a way of doing delegation rather than sub-classing? > > That is, can I create a class (say RF) that passes some of its methods > to Fraction for implementation but always returns an RF?
Hmm. The key here is that you want more than just delegation; you want to transform every return value. That's not going to be easy. It would be easiest and cleanest to skip the whole thing, and have a separate function for what you're doing here - not a method, a stand-alone function. def is_integer(fr): return fr.numerator % fr.denominator == 0 Next best would be the monkey-patching option. Delegation with transformation is a lot of effort for what you want. ChrisA -- https://mail.python.org/mailman/listinfo/python-list