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


26 bookmarks. First posted by toph may 2018.


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. It is created using the new @dataclass decorator, as follows:
Archive  python 
july 2018 by ronert
Data classes are one of the new features of Python 3.7. With data classes you do not have to write boilerplate code to get proper initialization, representation and comparisons for your objects.
programming  python  docs 
june 2018 by cito
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.
may 2018 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 
may 2018 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…
may 2018 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 
may 2018 by gmisra
The Ultimate Guide to Data Classes in Python 3.7 – Real Python
from twitter_favs
may 2018 by bjtitus
Data Classes in Python 3.7: an interesting new feature. Less boilerplate, type safety
from twitter_favs
may 2018 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
may 2018 by toph