
Introduction to Python's Dataclasses Module
I took two tutorials on the dataclass module offered by ArjanCodes. o The first tutorial “If you're not using Python DATA CLASSES yet, you should”. The length of the tutorial is 00:11 total video hours. o The second tutorial “This Is Why Python Data Classes Are Awesome”. The length of the tutorial is 00:22 total video hours. Data classes are suitable to model classes that represent data, and as such, they offer easy mechanisms to initialize, print, order, sort, and compare data. In these tutorials, the instructor also showed new capabilities that have been added in Python 3.10. From these tutorials, I learned how to generate simple dataclasses being able • to provide default values using a default factory like a list or supply a function to provide a default value • Excluding some information from what I print • Use `__post_init__()` to augment object with extra generated after it has been initialized • use `frozen` and `__post_init__()` to make sure that default date is not changed • use `sort_index` and `__post_init__()` to sort by specific attribute • use `serach_string` and `__post_init__()` to generate a value from other instance variables • customize representation by using `__str__` • keyword only argument that I can pass to a dataclass decorator You can find these tutorials at · https://www.youtube.com/watch?v=vRVVyl9uaZc&t=12s&ab_channel=ArjanCodes · https://www.youtube.com/watch?v=CvQ7e6yUtnw&t=4s&ab_channel=ArjanCodes