[Python-ideas] Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-16 Thread Steve Jorgensen
I feel like this proposal is not quite right, but maybe the idea will provoke some thoughts about something similar that -would- be right. The idea first came to me upon realizing that since `namedtuple` classes have no special base class beyond `tuple`, there should be some way of identifying

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-16 Thread Ricky Teachey
This is the kernel of a really useful idea, IMO. In fact, I already proposed something related to this-- unification of dict-making APIs-- back in May: https://mail.python.org/pipermail/python-ideas/2019-May/056491.html But I like the Struct ABC approach you've suggested, too. --- Ricky. "I've

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-16 Thread Steven D'Aprano
On Wed, Oct 16, 2019 at 05:27:31PM -, Steve Jorgensen wrote: > I feel like this proposal is not quite right, but maybe the idea will provoke > some thoughts about something similar that -would- be right. > > The idea first came to me upon realizing that since `namedtuple` > classes have no

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-16 Thread MRAB
On 2019-10-16 21:48, Steven D'Aprano wrote: On Wed, Oct 16, 2019 at 05:27:31PM -, Steve Jorgensen wrote: I feel like this proposal is not quite right, but maybe the idea will provoke some thoughts about something similar that -would- be right. The idea first came to me upon realizing th

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-16 Thread Andrew Barnert via Python-ideas
On Oct 16, 2019, at 13:48, Steven D'Aprano wrote: > > I don't think that "structural" is the word you are looking for. Lists > and tuples and sets are all structural. That's why they're called "data > structures". I think what he’s looking for is the adjective that goes with the quasi-word “s

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-16 Thread Kyle Stanley
> Maybe borrowing a word from a different language—record or datatype or something—would avoid that problem? Hmm, I don't think "record" would work. The terms "record", "struct", and "tuple" are far too synonymous with one another ( https://en.wikipedia.org/wiki/Record_(computer_science)). This te

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-16 Thread Greg Ewing
Andrew Barnert via Python-ideas wrote: I think what he’s looking for is the adjective that goes with the quasi-word “struct” as used in C, and in Python’s ctypes and C API. The type name “Struct” isn’t bad here, but the adjective “structural” has to many other connotations. Structy type? Struct

[Python-ideas] PEP 584: Add + and += operators to the built-in dict class.

2019-10-16 Thread Brandt Bucher
At long last, Steven D'Aprano and I have pushed a second draft of PEP 584 (dictionary addition): https://www.python.org/dev/peps/pep-0584/ The accompanying reference implementation is on GitHub: https://github.com/brandtbucher/cpython/tree/addiction This new draft incorporates much of the feed

[Python-ideas] Re: Add collections.abc.Struct as virtual base class of namedtuple classes and dataclass-decorated classes.

2019-10-16 Thread Andrew Barnert via Python-ideas
On Oct 16, 2019, at 22:13, Kyle Stanley wrote: > > > Maybe borrowing a word from a different language—record or datatype or > > something—would avoid that problem? > > Hmm, I don't think "record" would work. The terms "record", "struct", and > "tuple" are far too synonymous with one another >