On Thu, Apr 16, 2020 at 10:13 PM Kyle Stanley <[email protected]> wrote:
> Dominik Vilsmeier wrote:
> > I'm not sure if this is doable from the compiler perspective, but what
> > about allowing tuples after `**` unpacking:
> >
> > requests.post(url, **(data, params))
> >
> > # similar to
> > requests.post(url, data=data, params=params)
>
> +1. I can see the practical utility of the feature, but was strongly
> against the
> other syntax proposals so far. IMO, the above alternative does a great job
> of
> using an existing feature, and I think it would be rather easy to explain
> how
> it works.
>
If we go in that direction, I'd prefer curly braces instead so that it's
more reminiscient of a dict instead of a tuple, although technically it
will look like a set literal.
Some other possible syntaxes for a dict (which would have to be unpacked in
a function call) with string keys equal to the variable name, i.e. {"foo":
foo, "bar": bar}:
{*, foo, bar}
{**, foo, bar}
{:, foo, bar}
{{ foo, bar }}
{* foo, bar *}
{: foo, bar :}
{: foo, bar}
Personally in these cases I usually write dict(foo=foo, bar=bar) instead of
a dict literal because I don't like the quotes, but even then I'm sad that
I have to write the word 'dict'. So I would prefer that we covered raw
dicts rather than function calls, or both.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/SATYP4EW2ONMA4TFVFLWNILHTBWU3TNG/
Code of Conduct: http://python.org/psf/codeofconduct/