Reusing object methods?
Ivan Voras
ivoras at _-_fer.hr
Fri Apr 29 14:12:17 EDT 2005
Jp Calderone wrote:
>> I want to 'reuse' the same method from class A in class B, and without
>> introducing a common ancestor for both of them - is this possible in
>> an elegant, straightforward way?
>
>
> This is what sub-classing is for. If it makes you feel better, call it
> "mixing in" instead. You can share this method between two classes
> without inheritance (by defining a free function and then ...), but
> using a common base class really is just the right way to do it.
Ok.
More information about the Python-list
mailing list