frozen=True: Make Your Data Classes Read-Only

Table of Contents

frozen=True: Make Your Data Classes Read-Only

If you don’t want anybody to adjust the attributes of a class, use @dataclass(frozen=True).

In the example above, changing the attribute color of the DataClassDog‘s instance will throw an error.

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran