from dataclasses import dataclass, field

@dataclass
class Circle:
    __radius: field(init=True)

    @property
    def radius(self):
        return self.__radius

    @radius.setter
    def radius(self, r):
        assert r > 0, "Error radius < 0"
        self.__radius = r

    def __post_init__(self):
        self.radius = self.__radius
        print("Checking all attributes")
        print(f"Checking {self.radius=}")

    # def __init__(self, radius):
    #     self.__radius = radius
   #      self.__post_init__()

@dataclass(frozen=True)
class Rectangle:
    width: float
    height: float

# automatisch ein __init__
# automatisch ein __repr__
# automatisch ein __eq__

if __name__ == "__main__":
    c1 = Circle(2)
    print(c1.radius)
    c1.radius += 0.5
    print(c1.radius)
    print(c1)
    #  beides verbinden -> properties
    r1 = Rectangle(2, 5)
    print(r1.width, r1.height)
    r1 = Rectangle(r1.width + 2, r1.height)
    d = {r1: "Ein rechteck"}
    d[c1] = "Ein Kreis"  # __hash__
    # als dataclasses!