diff --git a/README.md b/README.md index d2f30c6..7652150 100644 --- a/README.md +++ b/README.md @@ -635,9 +635,23 @@ class Employee(Person): self.staff_num = staff_num ``` +### Comparable +```python +class MyComparable: + def __init__(self, a): + self.a = a + def __eq__(self, other): + # If not defined it returns id(self) == id(other). + if isinstance(other, MyComparable): + return self.a == other.a + return False + def __hash__(self): + return hash(self.a) +``` + ### Sequence ```python -class : +class MySequence: def __init__(self, seq): self.seq = seq def __len__(self):