multiple inheritance in Python?
David Goodger
dgoodger at bigfoot.com
Sun Jul 2 22:00:50 EDT 2000
on 2000-07-02 20:41, Sam Wun (swun at esec.com.au) wrote:
> Does anyone have example of implement multiple inheritance in Python?
My typelib.py module does (available at
http://gotools.sourceforge.net/sgflib in the sgflib.tgz archive). It defines
classes which emulate most of the Python built-in types (duplicating
functionality in UserList and UserDict, I know; I wrote it before I
"discovered" these two standard modules :). Multiple inheritance is emplyed
for common functionality reuse. For example, both the Number and String
classes support the "%" (modulo, or string formatting) operator, so that
functionality is implemented in the ModMixin class, which is inherited by
both classes along with other superclasses:
class Number(SuperType, AddMulMixin, ModMixin):
class Sequence(Container, AddMulMixin):
class String(Sequence, ModMixin):
Hope this helps.
--
David Goodger dgoodger at bigfoot.com Open-source projects:
- The Go Tools Project: http://gotools.sourceforge.net
(more to come!)
More information about the Python-list
mailing list