On 3/23/2022 5:03 PM, firstname.lastname@example.org wrote:
Back in early 2016 there was an idea submitted 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.
The proposal ultimately is the same as before:
my_point = (x=12, y=16) # (x=12, y=16) my_point # 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.