Polymorphism the Python way
Bertel Lund Hansen
nospamius at lundhansen.dk
Tue Sep 2 16:34:37 CEST 2003
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.
More information about the Python-list