> On May 11, 2019, at 11:12 PM, Christopher Barker <python...@gmail.com> wrote:
> 
>> 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.

That section mentions why they’re not iterable. Search on “iterable”.

> 
> if dataclasses *were*iterable, they almost certainly wouldn't iterate over 
> the values alone.

That wouldn’t make a difference. The given NT example would still be a problem. 

> 
> 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.

That approach of adding support for iterability makes sense to me. I’m 
contemplating adding a “dataclasses_tools” package for some other tools I have. 
But I’m not sure how this fits in to the asdict discussion. 

Eric

> 
> 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/
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to