Variable inheritance

Oleg Broytmann phd at
Tue May 22 04:09:44 EDT 2001

On Tue, 22 May 2001, Roman Suzi wrote:
> Can anyone provide an example where MI is used for right purpose,
> not just to quickly hack something?

   Easy. Think you are working with object of some classes. Let say there
are Animals and ColorThings. Imagine us constructing Animals hierarchy:

class Animal: ...

class Mouse(Animal): ...

class Elephant(Animal): ...

   Now to color things:

class ColorThings:
   color = "no color"

class Red(ColorThings):
   color = "red"

class Grey(ColorThings):
   color = "grey"

   Now let us construct grey mouse:

class GreyMouse(Grey, Mouse): pass

   What about red elephant? :)

     Oleg Broytmann              phd at
           Programmers don't die, they just GOSUB without RETURN.

More information about the Python-list mailing list