dataclasses — Data Classes — Python 3.14.7 documentation

docs.python.org

Tin mới

warnings — Warning control

contextlib — Utilities for with-statement contexts

Python Module Index

3.14.7 Documentation

The Python Standard Library

Python Runtime Services

object.__setattr__

frozen: If true (the default is False), assigning to fields will generate an exception. This emulates read-only frozen instances. See the discussion below.

MappingProxyType()

metadata: This can be a mapping or None. None is treated as an empty dict. This value is wrapped in MappingProxyType() to make it read-only, and exposed on the Field object. It is not used at all by Data Classes, and is

Mutable default values¶

Python stores default member variable values in class attributes. Consider this example, not using dataclasses: