This is an old copy of the Python FAQ. The information here may be outdated.

How can I organize my code to make it easier to change the base class?

You could define an alias for the base class, assign the real base class to it before your class definition, and use the alias throughout your class. Then all you have to change is the value assigned to the alias. Incidentally, this trick is also handy if you want to decide dynamically (e.g. depending on availability of resources) which base class to use. Example:

if sys.platform == "win32":
    BaseAlias = WindowsBaseClass
    BaseAlias = UnixBaseClass

class Derived(BaseAlias):
    def meth(self):

CATEGORY: programming


A Django site. rendered by a django application. hosted by webfaction.