Objects and behaviour
What is a class?
On this page
A class describes a family of instances and commonly supplies shared behaviour and a way to initialise each instance. In Python, two calls to list() create distinct lists that share the append method. Fields intended to differ per instance should be initialised on that instance.
Worked example
Pythonclass Batch:
def __init__(self):
self.jobs = []
first, second = Batch(), Batch()
first.jobs.append("thumbnail")
assert second.jobs == []Explore class relationships in the OOP Playground