Python composition vs inheritance: The has-a and is-a relationships

Python composition vs inheritance: The has-a and is-a relationships

Writing object-oriented Python? Don’t confuse the two core relationships:

– has-a (“composition”). One object contains another. A Person has-a name. A Car has-a color.
– is-a (“inheritance”). One class is similar to an existing one. An Employee is-a Person. A Car is-a Vehicle.