Variable inheritance

Oleg Broytmann phd at phd.fep.ru
Tue May 22 10:09:44 CEST 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.
----
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list