If you want to dive into all the details of data classes, have a look at PEP 557 as well as the discussions in the original GitHub repo.
In addition, Raymond Hettinger’s PyCon 2018 talk Dataclasses: The code generator to end all code generators is well worth watching.
In this course, you’ve learned how to:
- Define your own data classes
- Add default values to the fields in your data class
- Customize the ordering of data class objects
- Work with immutable data classes
If you aren’t using Python 3.7 or later, there’s also a data classes backport for Python 3.6. And now, go forth and write less code!
Jon Nyquist on Sept. 15, 2021
Nice class! (pun intended) Can you put a pandas dataframe in a data class? Would you want to?