Composition of classes instead of multiple inheritance

Category: Python - Miscellaneous

MI can be difficult and confusing, and if the base classes don't cooperate -- well, cooperative MI won't work.

One way around this is to use composition instead. This class decorator will combine the source classes with the target class, ensuring that no duplications occur (raises a TypeError if there are any). Date: 12 February, 2012


Class Decorator - Composition - Inheritance - Multiple Inheritance

Homepage: http://code.activestate.com/recipes/577658-composition-of-classes-instead-of-multiple-inherit/?in=lang-python

Developer: Ethan Furman

License: Freeware

Operating System: Windows

Add a Comment

all are required fields

     
What do you think of this resource?

Select Your Rate:

Votes:0

 

Related Scripts Download

total_ordering and force_total_ordering are class decorators for
Python 2.

developer Developer: Michael Foord
license License: Freeware
operating systems Operating System: Windows


In most of the object oriented codes we write, we need to set class attributes to the given argument values and this is a very line-consuming thing.

developer Developer: Ahmet Emre Aladag
license License: Freeware
operating systems Operating System: Windows


This script contains two classes that show two styles of function composition.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


The athenaCL system is an open-source, object-oriented composition tool written in Python.

developer Developer: SourceForge.net
license License: Artistic License, GNU General Public License (GPL)
operating systems Operating System: Windows, Linux, Mac OS, BSD, Solaris


This tutorial covers how to get most out of the Object Oriented Programming Conecpts using C++ Language.

developer Developer: mycplus.com
license License: Freeware
operating systems Operating System: All


Dot is a very nice graph description language developed at MIT.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


Python classes cannot inherit from any type, just from other classes.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


Provides a data structure for a queue of integers whose get() method returns the median element.

developer Developer: Alessandro Presta
license License: Freeware
operating systems Operating System: Windows


This script allows how to transparently install a HTTP proxy (proxy HTTP 1.

developer Developer: Raphael Jolivet
license License: Freeware
operating systems Operating System: Windows