3 ms·
Used it all the time in my commercial python jobs. The other common one is namedtuple.
by ReflectedImage 5y ago
Used it all the time in my commercial python jobs.
The other common one is namedtuple.
- skindoe 5y agoData classes are far superior than named tuples of you are using 3.7 or higher
- gradys 5y agoShout out to the attrs library. If you find yourself using namedtuple a lot, it's worth considering despite it being an external dependency. https://www.attrs.org/en/stable/ https://www.attrs.org/en/stable/
- re 5y agoData Classes, built into Python since 3.7, are like a somewhat simplified version of the attrs library. I use them in most situations where I would have previously used namedtuple. https://www.python.org/dev/peps/pep-0557/ https://www.python.org/dev/peps/pep-0557/