9.2 An alternative to method overloading
One prominent feature of some object-oriented programming languages is a feature called method overloading. Method overloading refers to having multiple method definitions with the same name, each of which accept different sets of parameters. In statically typed languages, this is useful if we want to have a method that accepts either an integer or a string, for example. In non-object-oriented languages, we might need two functions, called add_s() and add_i() — one for strings, one for integers — to accommodate such situations. In statically typed object-oriented languages, one approach is to permit definition of two methods, both called add, one that accepts strings, and one that accepts integers.
In Python, we’ve already seen that we only need one method, which accepts any type of object. It may have to do some matching of the object’s type (for example, if it is a string, convert it to an integer...