Re: [Python-ideas] Consider adding an iterable option to dataclass

2018-08-13 Thread Ivan Levkivskyi
On 11 August 2018 at 01:29, Eric V. Smith wrote: > On 8/10/2018 7:01 PM, Neil Girdhar wrote: > >> [...] > > [...] > >> sequence would simply inherit from collections.abc.Sequence and implement >> the two methods __len__ and __getitme__. >> > > Unless I'm misunderstanding you, this falls in to

Re: [Python-ideas] Consider adding an iterable option to dataclass

2018-08-11 Thread Neil Girdhar
My only motivation for this idea is so that I can forget about namedtuple. Thinking about it again today, I withdraw my suggestion until I one day see a need for it. On Fri, Aug 10, 2018 at 10:14 PM Eric V. Smith wrote: > On 8/10/2018 7:01 PM, Neil Girdhar wrote: > > It would be nice if

Re: [Python-ideas] Consider adding an iterable option to dataclass

2018-08-10 Thread Eric V. Smith
On 8/10/2018 7:01 PM, Neil Girdhar wrote: It would be nice if dataclasses (https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass) had an option to make them a sequence.  This would make dataclass(frozen=True, order=True, sequence=True) an optionally-typed version of

Re: [Python-ideas] Consider adding an iterable option to dataclass

2018-08-10 Thread Steven D'Aprano
On Fri, Aug 10, 2018 at 04:01:59PM -0700, Neil Girdhar wrote: > It would be nice if dataclasses > (https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass) > had an option to make them a sequence. Do you have a use-case or reason for this other than "it would be nice"? Nice in