https://docs.python.org/3.12/library/dataclasses.html
https://www.attrs.org/en/stable/examples.html
from dataclasses import dataclass
@dataclass(order=True)
class A(object):
name: str
age: int
# def __init__(self):
# print(234)
def __post_init__(self):
print(234)
a = A("2", 2)
a2 = A(name="2", age=2)
print(a.name, a2.age)
print(a == a2)
网友评论