@dataclass
      class ClassName:
      	val: int
        val2: float = 0.0  # assigning default value
      Python language logo

      Dataclass

      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

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.