On 29 Jul 2014 08:16, "Alexander Heger" <python@2sn.net> wrote:
In all honesty, I'd suggest that code which looks bad enough to warrant even considering this feature is probably badly in need of refactoring, at which point the problem will likely go away.
I often want to call functions with added (or removed, replaced) keywords from the call.
args0 = dict(...) args1 = dict(...)
def f(**kwargs): g(**(arg0 | kwargs | args1))
currently I have to write
args = dict(...) def f(**kwargs): temp_args = dict(dic0) temp_args.update(kwargs) temp_args.update(dic1) g(**temp_args)
The first part of this one of the use cases for functools.partial(), so it isn't a compelling argument for easy dict merging. The above is largely an awkward way of spelling: import functools f = functools.partial(g, **...) The one difference is to also silently *override* some of the explicitly passed arguments, but that part's downright user hostile and shouldn't be encouraged. Regards, Nick.
It would also make the proposed feature to allow multiple kw args expansions in Python 3.5 easy to write by having
f(**a, **b, **c) be equivalent to f(**(a | b | c))
-Alexander _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/