Dataclasses in Python
The dataclass()
decorator will add various “dunder” methods to the class
https://docs.python.org/3/library/dataclasses.html
The parameters to dataclass()
are:
init
: If true (the default), a__init__()
method will be generated. If the class already defines__init__()
, this parameter is ignored.
repr
the repr() function is used to get a printable string representation of an object
repr
: If true (the default), a__repr__()
method will be generated. The generated repr string will have the class name and the name and repr of each field, in the order they are defined in the class.
repr can be passed to eval() whereas str can not.