More on Classes

In this section you will learn about operator overloading. That is, the ability to use operators such as "+" with objects that you create.

Readings from the book The Practice of Computing Using Python.

Chapter 12: More on Classes

Videos

  1. Overloading Operators (Video I, Video II, Video III)
  2. Example code to overload the "+" operator for MyClass

    class MyClass (object):
        def __add__ (self, operand2):
            suite-of-statements  # calculate result 
            # call constructor so returned object is of class type (closure)
            return MyClass(result) 
  • Inheritance (Video I, Video II)
  • Chapter 12 Exercises on Mimir.
  • Lab12 (do pre-lab first on D2L)
  • Project11