@dataclass
is a decorator which is part of the Python dataclasses
module. When the @dataclass
decorator is used, it automatically generates special methods such as:
_ _ init _ _.
: Constructor to initialize fields_ _ repr _ _
: String representation of the object_ _ eq _ _
: Equality comparison between objects_ _ hash_ _
: Enables use as dictionary keys (if values are hashable)
Along with the methods listed above, the @dataclass
decorator has two important attributes.