On Sat, May 11, 2019 at 3:26 PM Eric V. Smith <e...@trueblade.com> wrote:
> It’s a design goal of dataclasses to not be iterable. > > https://www.python.org/dev/peps/pep-0557/#why-not-just-use-namedtuple > you would know, but that reference talks about why they are not the same as NamedTuple. if dataclasses *were*iterable, they almost certainly wouldn't iterate over the values alone. And NamesTuple was designed to BE tuples -- that is a drop in replacement for tuples -- so they have the features they have partially for that reason. And my toy code actually adds another decorator to make dataclasses iterable, so it would be a completely optional feature. All that being said, I'm not actually advocating doing this with dataclasses -- I'm simply making the point that there are currretly two ways to make custom class able to be passed in to the dict constructor -- do we need another? -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/