Staging: this is not the live site, pydocs.org.
dataclasses This module provides a decorator and functions for automatically adding generated special methods such as __init__() and __repr__() to user-defined classes. It was originally described in PEP 557. © Python Software Foundation. PSF License Version 2 · Official docs ↗
Symbols in dataclasses _ __post_init__ When defined on the class, it will be called by the generated __init__(), normally as self.__post_init__(). a asdict Return the fields of a dataclass instance as a new dictionary mapping field names to field values. astuple Return the fields of a dataclass instance as a new tuple of field values. d dataclass Add dunder methods based on the fields defined in the class. f field Return an object to identify dataclass fields. Field Field objects describe each defined field. fields Return a tuple describing the fields of this dataclass. FrozenInstanceError Raised when an implicitly defined __setattr__() or __delattr__() is called on a dataclass which was defined with frozen=True. i InitVar InitVar[T] type annotations describe variables that are init-only. is_dataclass Returns True if obj is a dataclass or an instance of a dataclass. k KW_ONLY A sentinel object used as a type annotation. m MISSING A sentinel object signifying a missing default or default_factory. r replace Return a new object replacing specified fields with new values.
Python docs © Python Software Foundation · Examples CC0 ·
Source on GitHub · Not affiliated with the PSF