Python Arena

Module 43

Object oriented programming techniques

Making your own objects work with Python's operators and loops. Methods that return objects, comparisons with < and ==, arithmetic with + and -, a technical text for an object with __repr__, and iterators that let a for loop go through your object.

Steps

  1. Comparing objects with operators
  2. Equality with __eq__
  3. Arithmetic operators
  4. __str__ and __repr__
  5. Iterators