June 2002
Beginner to intermediate
640 pages
14h 24m
English
Of the three pillars of OOP, inheritance and encapsulation are nice to have but polymorphism is the true key to OOP's success. Polymorphism gives objects the most important feature of all: replaceability.
There are two forms of polymorphism: late-bound and typed. Visual Basic uses late-bound, whereas Java uses typed. Python polymorphism is a hybrid of the two.
In Python, late-bound polymorphism means that class instances can appear to be other objects if their class implements special methods. Thus, because a function is an object, a class can act like a function just by implementing a special method. Numeric types are also objects, so with special methods a class can act like a numeric type.
For example, ...
Read now
Unlock full access