Browse OOP reference
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

Python
class Batch:
    def __init__(self):
        self.jobs = []

first, second = Batch(), Batch()
first.jobs.append("thumbnail")
assert second.jobs == []

Python tutorial on classes

Explore class relationships in the OOP Playground

What is a method?How do modern languages approach object orientation?What is method overloading?

All OOP questions

Search ObjectFAQ