[Python-Dev] repeated keyword arguments
scott+python-dev at scottdial.com
Sat Jun 28 04:11:03 CEST 2008
Steven D'Aprano wrote:
> It would be nice to be able to do this:
> defaults = dict(a=5, b=7)
> f(**defaults, a=8) # override the value of a in defaults
I can't help but think that would be difficult coding convention to use.
However, I'm considerably less bothered by:
defaults = dict(a=5, b=7)
The only way f(**defaults, a=8) would be useful is if it happens a lot,
and in that case, it's just as good of a candidate for being made into a
function itself. I see this pattern all the time, and given that
"f_with_defaults" probably has some semantic meaning, it probably would
be nice to give it it's own name ("g").
Just my 2 cents.
scott at scottdial.com
scodial at cs.indiana.edu
More information about the Python-Dev