building embedded classes as in C/C++

Tres Seaver tseaver at
Thu Aug 5 05:33:15 CEST 1999

In article <slrn7qf4g2.3vvqed5.mmorris at>,
Mitchell Morris <mmorris at> wrote:

>Of course it is ... everything is possible in Python, since it is Turing
>complete. On a different philosophical note, there are two concepts which
>can be expressed best by inheritance (according to the conventional C++
>wisdom which I'll parrot to the best of my ability).
>The most common notion is "is-a", modeled in C++ by public inheritance.
>For example, "class Penguin(Bird)" conceptually represents the notion that a
>penguin is a bird and thus could be expected to do anything a bird can do and
>respond to any input that other birds would respond to.
>The other common notion expressed by inheritance is "is-implemented-by".
>For example, "class TCPSocket(File)" conceptually means that a TCPSocket
>works exactly like a file, so we'll be stealing his methods directly instead
>of writing our own. In C++ this would likely be accomplished through
>private inheritance.
>Extra credit if you can think of an example that matches protected

"Ooh! ooh!"  The classic usage is to model "is-implemented-by-for-my-kids-sake"

		 |             |
    (protected)  (public,virtual)
		 |             |
   CommonFooImpl       |
		 ^             +

The derived classes can exploit the AbstractFoo-ness of CommonFooImpl, but
nobody else can.

>Since your example classes "Object" and "Point" actually model neither 
>"is-a" nor "is-implemented-by", you may take as a first approximation that
>inheritance isn't going to work for you here.
>hoping-some-of-this-helps-ly y'rs,
>(Dang, now you've got me hyphenating!)



Tres Seaver           tseaver at       713-523-6582
Palladion Software

More information about the Python-list mailing list