[Python-Dev] repeated keyword arguments
Steven D'Aprano
steve at pearwood.info
Sat Jun 28 03:58:41 CEST 2008
On Sat, 28 Jun 2008 11:17:10 am Greg Ewing wrote:
> tomer filiba wrote:
> > >>> def f(**kwargs):
> >
> > ... print kwargs
> > ...
> >
> > >>> f(a=5,b=7,a=8)
> >
> > {'a': 8, 'b': 7}
>
> I can't think of any reason why one would need to be
> able to write such code, or even want to.
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
but unfortunately that gives a syntax error. Reversing the order would
override the wrong value. So as Python exists now, no, it's not
terribly useful. But it's not inherently a stupid idea.
--
Steven
More information about the Python-Dev
mailing list