Verbose and flexible args and kwargs syntax

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Dec 12 20:34:37 EST 2011


On Mon, 12 Dec 2011 16:58:33 -0500, Terry Reedy wrote:

> On 12/12/2011 12:12 PM, Eelco wrote:

>> Yes, we can cast the list to be whatever we want on the next line,
> 
> Convert. For the very few cases one wants to do this, it is quite
> adequate.

+1

with the small proviso that there's not much you can usefully do with a 
dict. If you convert to an ordered dict, the initial order is lost by the 
time you see it; if you want to allow duplicates, duplicates are likewise 
lost (or in a function call, an exception is raised).

In Python 4000, I'd like to see some way to pass arbitrary parameters to 
functions, including duplicates. That is, emulating the richness of 
command line argument handling in functions.

In Python 3.x, I'd like to see OrderedDict become a built-in, and then 
**kwargs can collect named arguments in an ordered dict without losing 
the order.



-- 
Steven



More information about the Python-list mailing list