Lines 36–44 overload the + operator for addition
when a SingleList appears to the left or right of the
operator. Methods __add__ and __radd__
each return a new object of class SingleList that is
initialized with the elements of the two arguments passed to either
method. This operation has the same effect as merging two lists into one
list of
reference. Lines 55–62 overload the multiplication operation (i.e.,
list repetition) for
objects of class SingleList. By definition, a
SingleList cannot contain more than one occurrence of
any value, so method __mul__ raises an exception if the
client attempts such an operation. Line 62 binds the names for methods
__rmul__ (right multiplication) and
__imul__ (augmented assignment multiplication) to the
method defined for __mul__; when clients invoke these
operations, the corresponding methods also raise exceptions.