The Ultimate Guide to Data Classes in Python 3.7 – Real Python


23 bookmarks. First posted by toph 9 days ago.


While this is not much more code to write, you can already see signs of the boilerplate pain: rank and suit are both repeated three times simply to initialize an object. While this might seem like a good thing, this lack of awareness about its own type can lead to subtle and hard-to-find bugs, especially since it will also happily compare two different namedtuple classes: The attrs project is great and does support some features that data classes do not, including converters and validators. In addition to tuple , dict , namedtuple , and attrs , there are many other similar projects , including typing.NamedTuple , namedlist , attrdict , plumber , and fields . In fact, adding some kind of type hint is mandatory when defining the fields in your data class.
3 days ago by sechilds
"One new and exciting feature coming in Python 3.7 is the data class. A data class is a class typically containing mainly data, although there aren’t really any restrictions. [...] A data class comes with basic functionality already implemented. For instance, you can instantiate, print, and compare data class instances straight out of the box"
python  programming  class  tutorial 
6 days ago by shello
Table of Contents Alternatives to Data Classes Basic Data Classes Default Values Type Hints Adding Methods More Flexible Data Classes Advanced Default Values…
6 days ago by wesleythill
Alternatives to Data Classes
Basic Data Classes
Default Values
Type Hints
Adding Methods
More Flexible Data Classes
Advanced Default Values
You Need Representation?
Comparing Cards
Immutable Data Classes
Inheritance
Optimizing Data Classes
Conclusion & Further Reading
programming  python 
6 days ago by gmisra
The Ultimate Guide to Data Classes in Python 3.7 – Real Python
from twitter_favs
7 days ago by bjtitus
Data Classes in Python 3.7: an interesting new feature. Less boilerplate, type safety
from twitter_favs
8 days ago by rukku
Table of Contents Alternatives to Data Classes Basic Data Classes Default Values Type Hints Adding Methods More Flexible Data Classes Advanced Default Values…
from instapaper
9 days ago by toph