I agree that introducing a new way for creating implicit dict literals
only for the purpose of saving on keyword arguments seems too much of a
change. Although it would be an elegant solution as it builds on already
existing structures. And I don't think it hurts readability for function
calls, since all your examples could be written as:

    bar(**{:a, :b, :c}, **kwargs)

This doesn't have the problem of accidentally overriding keys as it is
similar to:

    bar(a=a, b=b, c=c, **kwargs)


On 17.04.20 06:41, oliveira.rodrig...@gmail.com wrote:
I believe this is a different feature, non-exclusive to the one proposed here, 
that would also make it possible not to re-declare keywords.

But implementing this change with the argument of making function calls less 
repetitive or verbose when having redundant named keywords and variables 
doesn't sell it to me.

See, function calls would still suffer to be less redundant if we go with this:

```python
def foo(a, b, **kwargs):
     c = ...
     bar(**{:a, :b, :c, d: kwargs["d"]})  # this just got worse
```

```python
def foo(a, b, **kwargs):
     c = ...
     # all parameters definition is away from the function call, not a fan
     # one can possibly overwrite some key on kwarg without knowing
     kwargs.update({:a, :b, :c})
     bar(**kwargs)
```

```python
def foo(a, b, **kwargs):
     c = ...
     bar(**(kwargs | {:a, :b, :c}))  # a little better but one can still 
overwrite some key on kwarg without knowing
```

Using a "magical" separator does the job and has little interactions with other 
syntaxes, using the `*` character seems better than just picking another random one (like 
we did with `/`). Comparing with all the above excerpts, this is still more appealing and 
clearer for me:

```python
def foo(a, b, **kwargs):
     c = ...
     bar(*, a, b, c, **kwargs)  # also, if any of `a`, `b` or `c` is in 
`kwargs` we get a proper error
```

Rodrigo Martins de Oliveira
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ATCTNM5DTDTXLLCOFEHDHM7OP2MYTQDW/
Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/GI6UDR5OU7H7Q46STLTWBQ3CLUEIWW2K/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to