[Python-ideas] Ordered storage of keyword arguments

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Oct 29 06:26:30 CEST 2010


On 29/10/10 13:54, Nick Coghlan wrote:

> The use case is being able to interface naturally with any key-value
> API where order matters.
>
> For example:
>
> # Create an ordered dictionary (WRONG!)
> d = OrderedDictionary(a=1, b=2, c=3) # Order is actually arbitrary due
> to unordered kw dict

I'd need convincing that the API wouldn't be better designed
to take something other than keyword arguments:

   d = OrderedDictionary(('a', 1), ('b', 2), ('c', 3))

and have it refuse to accept keyword arguments to prevent
accidents.

-- 
Greg




More information about the Python-ideas mailing list