Just like __add__
there are other methods we can use to overwrite the operators in Python.
- _sub_: This method can be used to overload the
-
operator.
- _mul_ : This method can be used to overload the
*
operator.
- _truediv_: This method can be used to overload the
/
operator.
- _mod_: This method can be used to overload the
%
operator.
- _lshift_: This method can be used to overload the
<<
operator.
The example above shows the use of the left-shift operator <<
to move items from one basket to another.