Order of keyword arguments

Gordon McMillan gmcm at hypernet.com
Sun Nov 21 13:15:45 EST 1999


Andres Corrada wrote:

> Jeff wrote:
> 
> > ....................................................... but I
> > don't see the advantage to 'knowing' the order that the
> > keywords were used by the calling function.
> > 
> 
> I think there would be an advantage to having such a data
> structure as an ordered dictionary. My "American Heritage
> Dictionary of the English Language" is such a data structure.

Ah, but that would be "alphabetical order", not "entry order", 
and not much use to anybody if it were.

Python data structures that would suit your apparent desires:
 [ (optionname, optionvalue), ... ]

 [ optionname, ...], {optionname: optionvalue, ...}

You could subclass UserList to provide the intended 
semantics, and then force your poor, hapless user to pass in 
exactly one arg (an instance of your UserList subclass).

Or you could ponder the meaning of cheese. 

With approximately equal utility.

- Gordon




More information about the Python-list mailing list