A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-June/080810.html below:

[Python-Dev] repeated keyword arguments

[Python-Dev] repeated keyword argumentsScott Dial 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:

def f_with_defaults(**kw):
     defaults = dict(a=5, b=7)
     defaults.update(kw)
     return f(**defaults)
f_with_default(a=8)

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 Dial
scott at scottdial.com
scodial at cs.indiana.edu
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4