Polymorphism the Python way

Jacek Generowicz jacek.generowicz at cern.ch
Wed Sep 3 17:38:46 CEST 2003

alan.gauld at btinternet.com (Alan Gauld) writes:

> On Tue, 02 Sep 2003 16:34:37 +0200, Bertel Lund Hansen
> <nospamius at lundhansen.dk> wrote:
> > "Encapsulation" is the word that describes the effort(s) to make
> > it impossible for the user of a module to access the attributes
> > (and hidden methods) directly and only allow him to do it through
> > public methods with build-in check so that no disasters occur.
> <RANT>
> Does anyone else really hate this corruption as much as me?

Yes. Me.

> Encapsulation in OO originally meant the ability to bind data and
> functions together into a single thing (that we call an object).

> The ability to hide the internal data was called data hiding

I make a point of stating this in my Python courses.

> Polymorphism (whether based on inheritance (like C++) or inteface
> (like Python)).

Yes, I also make a point stating that (dynamic) polymorphism is
orthogonal to inheritance (unless your language is fundamentally
flawed :-)

> I've been trying to find the exact point when encapsulation
> changed its meaning to data hiding but without success.

I don't think that it has changed its meaning; most people just use
the term incorrectly.

Similarly, I don't think that the meaning of "pizza's" has changed
just because most people insist on writing "pizza's" when they really
mean "pizzas" (as in "please give me five pizza's")[1].

I have similar feelings about the orthogonality of the static-dynamic
and strong-weak typing axes ... just because most people say that
Python is weakly typed, doesn't mean that it is, or that the meaning
of "weakly typed" has changed.

But I guess that I am plain wrong: given that there is no Academy of
English to govern its use, majority use determines meaning.

> Sorry, just had to get that off my chest! :-)

I know the feeling. It was only a lack of time that prevented me from
doing so myself, on first reading of the original.

[1] Of cour'se, this is not about pizza's, but the abu'se of
    apostrophe's in general.

More information about the Python-list mailing list