Using Data Classes in Python

·

1 min read

Data Classes are a recent addition to Python's newer versions of releases, version 3.7 onward. These structures are not very different from a normal python class but few enhancements make it suitable to store data.

As the name suggests, these are a special kind of classes that are used to store only the data. An example data class is as below:

from dataclasses import dataclass

@dataclass
class Rectangle(object):
     length: float
     breadth: float