starlark icon indicating copy to clipboard operation
starlark copied to clipboard

Permit multiple **kwargs arguments

Open ndmitchell opened this issue 4 years ago • 3 comments

Given the function call f(**a, **b) the meaning is clear and precise. But the best Starlark-compliant alternative I could find is:

x = dict(a)
a.update(b)
f(**x)

That seems more complex, and it's easy to get it wrong, and it doesn't error if a key is repeated (unlike before).

Given an extension to multiple **kwargs, I see no reason not to allow it for *args too, although there the argument is weaker.

ndmitchell avatar Feb 25 '21 09:02 ndmitchell

We could instead support the python3 {**a, **b} syntax for constructing/merging dicts, which would make your call instead look like:

f(**{**a, **b})

which is valid python3.

illicitonion avatar Feb 25 '21 09:02 illicitonion

Yep, that would be great too.

ndmitchell avatar Feb 25 '21 10:02 ndmitchell