· intermediate
Object-Oriented Python
Bundle state and the behaviour that acts on it. Classes, instances, inheritance and composition, and the protocol methods that make your own types feel like Python's built-in ones.
Written in house, from the work rather than from a syllabus. Every example is one we would use ourselves, and every exercise is checked against the same engine that grades your answer.
What you’ll learn
- Define a class with __init__ and give each instance its own state
- Write methods that act on the instance rather than on globals
- Share behaviour with inheritance and call up with super()
- Choose composition over inheritance when the relationship is has-a
- Implement __repr__, __eq__ and __len__ so your types behave predictably
- Cut boilerplate with dataclasses and guard attributes with property
Before you start
- · Comfortable writing and calling functions
- · Familiar with lists and dictionaries