On 3/23/2022 5:03 PM, mich...@michaelgreen.dev wrote:
Back in early 2016 there was an idea submitted[1] by Joseph Martinot-Lagarde in 
regard to anonymous namedtuples. The crux of the submission was the idea of 
instantiating a namedtuple using only Python's generic tuple syntax plus 
keyword arguments. At the time, the major rebuttal against this idea however 
was that, since kwargs are an unordered collection, it would be non-trivial to 
figure out a proper convention for mapping an unordered collection onto an 
ordered one.

Times have changed however, and with python3.6/3.7 we now have the guarantee 
that dictionaries are insertion ordered. This means that by extension keyword 
arguments are also ordered, and thus the major point of contest against 
anonymous namedtuples is now moot. And as such I would like to once again 
suggest anonymous namedtuples as a potential PEP.

Proposal
=======
The proposal ultimately is the same as before:
```
my_point = (x=12, y=16)
# (x=12, y=16)
my_point[0]
# 12
```
...
As we can see, the introduction of insertion-ordered dictionaries solves all of 
the issues previously raised with regard to anonymous namedtuples.

I don't think this is justifiable as built-in behavior. Just rename your function "t", then you can write t(x=12, y=16). That fact that it's not typing friendly is definitely as strike against it, in my opinion.

But if you really want to pursue it, it would definitely need a PEP, and someone to sponsor it.

Eric


_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/USTMRLNUOA3HCBINFBGAEQC4NONRLA6O/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to