Working with Dataclasses
Classes have been available in Python since the beginning, but writing a fully featured data-centered class required developers to write and test multiple special methods (a.k.a. dunder methods). In addition to the initial implementation, these methods needed to be maintained as the class gained or lost data fields.
In Python 3.7 the dataclasses module was introduced to the standard library (also available as a pip installable module for Python 3.6). This module makes it easier for developers to create user-defined classes, particularly custom data containers, by reducing the amount of code that they need to write, test, and maintain.
The code in this repo is the Hands-on exercises which are part of an web-based training course offered through the Safari Live Online Training platform. The course helps you explore and understand the features of the dataclasses module so that you can effectively use it to write better, more maintainable Python classes.
What you will learn-and how you can apply it
You will understand
- How dataclasses reduces the effort needed to create fully featured user-defined classes, particularly custom data containers
- How dataclasses compare to existing Python data structures
You will be able to
- Use the basic dataclasses to reduce the amount of effort needed to write Python classes
- Use the additional features of dataclasses to fine-tune and further customize your classes