Before we dive deeper into details of Python classes, we will take a small detour. We will discuss a relatively new addition to the Python language, which are data classes. The dataclasses module, introduced in Python 3.7, provides a decorator and function that allows you to easily add generated special methods to your own classes.
Consider the following example. We are building a program that does some geometric computation and want to have a class that allows us to hold information about two-dimensional vectors. We will display the data of the vectors on the screen and perform common mathematical operations, such as addition, subtraction, and equality comparison. We already know that we can use special methods to achieve that goal. We can implement our Vector class as follows:
class Vector:
def __init__(self, x, y):
self.x = x...