LS26 - Operator Overloading
Suppose you had a class named Fraction representing fractions like 1/2 or 3/4. Further suppose you have two Fraction objects named a and b. If you wrote the expression a + b, Python would look in your class and choose the first method whose first parameter is self and second parameter is of type Fraction.
F
You are encouraged to define as many overloads for classes you design as possible, even when it is a bit of a stretch of the imagination as to how a given operator relates to the logic you decided to use for it. The conciseness of operator overloading is always worthwhile.
F
Even though objects don't have the ability to use subscription notation inherently, you can overload the subscription operator by implementing the special __getitem__ method.
T
In Python, when you design a class you are able to define what it means when objects of your class are multiplied, added, and so on to other values.
T
Popular libraries will often make responsible use of operator overloading.
T
The Point class shown in the video for Operator Overloading has a __repr__ method that, based on the contents of the previous video, more correctly should have been named __str__.
T