[Python-ideas] Preserving **kwargs order

Terry Reedy tjreedy at udel.edu
Sat Apr 5 05:16:55 CEST 2014


On 4/4/2014 9:50 AM, random832 at fastmail.us 
wrote:
> On Fri, Apr 4, 2014, at 4:54, Terry Reedy wrote:
>> **kwds in a call is a substitute for writing out unordered key=value
>> specifications. The function may or may not have **kargs in its
>> signature and if it does, the kargs received may or may not be equal to
>> the kwds passed.
>
> The problem is, there is no such thing as "writing out unordered
> key=value specifications" - anything that is "written out" has an order
> by its nature;

Before being written, the key=value specification is unordered. The 
order introduced by writing it out in linear text is spurious.

 > the fact that this order is lost immediately is a poor
> abstraction. The desired use case is not to preserve the order of
> **kwds, it's to preserve the order of a sequence of key=value
> specifications.

Wanting to preserve spurious order is wrong.  What I said before is that 
if one has meaningful order, one should better use an ordered sequence, 
both in the definition and call of the function, rather than an 
unordered (or spuriously ordered) mapping.

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list