Dataclass

    0

    23

    Python public recipes

    A @dataclass annotation tells the compiler to create a class that acts as a data type. In this case, the @dataclass annotation tells the compiler to create a class that represents an integer value.

    The val field in this class is an int value that represents the integer value of the class.

    Shortcut: class.data

    @dataclass
    class ClassName:
    	val: int
      val2: float = 0.0  # assigning default value
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.