Tag: OOP

Object Oriented Programming: Comparing and inheritance

Overloading equality When comparing two objects of a custom class using ==, Python by default compares just the object references, not the data contained in the objects. To override this behavior, the class can implement the special __eq__() method, which accepts two arguments — the objects to be compared — and returns True or False....

Creating a subclass

The purpose of child classes — or sub-classes, as they are usually called – is to customize and extend functionality of the parent class.  Let’s call the Employee class from what we have done earlier. In most organizations, managers enjoy more privileges and more responsibilities than a regular employee. So it...