Class (Python)

A blueprint for objects with their own data (attributes) and functions (methods).

Also called: self, __init__, dataclass, object

Domain
Languages
Type
Term
Source
General
Language
Python

In plain English

self is the object itself. @dataclass writes the boring constructor for you.

Example

Each listing is an instance of the Listing class with a name and a city.

In code

from dataclasses import dataclass

@dataclass
class Listing:
    name: str
    city: str
    verified: bool = False

l = Listing("Warung Made", "Ubud")

Related terms

Added 2026-11-30 · Last reviewed 2026-11-30