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
[EMAIL PROTECTED]
[EMAIL PROTECTED]
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to