Polymorphism the Python way

Michael Peuser mpeuser at web.de
Tue Sep 2 14:40:42 EDT 2003


"Bertel Lund Hansen" <nospamius at lundhansen.dk> schrieb im Newsbeitrag
news:js99lvguv5vdvmmjfpdmgmo5dnq5akttfb at news.stofanet.dk...
> Daniel Klein skrev:
>
> >It's not a problem really. I just thought there would be a better,
> >more elegant way to achieve polymorphism without using getters.
>
> A note on words:
>
> If a class operates with for instance a bullet, then derived
> classes thereof may operate with a metal bullet, a rubber bullet,
> a grenade or a missile. They all operate as bullets, and the fact
> that the same object can be instantiated as many different
> things, is called polymorphism. "Poly morph" = "many shaped".
>
> "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.
>

There is another term: "overloading" and I put the OP's question in that
drawer. But I have lerned now, that "overloading" can be catalogued as
"ad-hoc-polymorphism" whereas the situation when applying a method of a base
class to an instance of a derived class is called "universal polymorphism"
;-)

Kindly
Michael P






More information about the Python-list mailing list