June 2019
Beginner to intermediate
770 pages
19h 24m
English
In this section, we'll flirt with the idea of pretty poor polymorphism. Inspection of argument value types is a Python programming practice that should be isolated to a few special cases. Later, when we look at numbers and numeric coercion, we'll learn about cases where the inspection of types is recommended.
Well-done polymorphism follows what is sometimes called the Liskov substitution principle. Polymorphic classes can be used interchangeably. Each polymorphic class has the same suite of properties. For more information, visit http://en.wikipedia.org/wiki/Liskov_substitution_principle.
Overusing isinstance() to distinguish between the types of arguments can lead to a needlessly complex (and slow) program. ...
Read now
Unlock full access