[Python-Dev] Any grammar experts?

Ethan Furman ethan at stoneleaf.us
Mon Jan 26 21:06:26 CET 2015


On 01/26/2015 11:39 AM, Petr Viktorin wrote:
> On Mon, Jan 26, 2015 at 8:29 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
>> On 01/26/2015 11:24 AM, Barry Warsaw wrote:
>>> On Jan 26, 2015, at 10:55 AM, Ethan Furman wrote:
>>>
>>>> In the your example
>>>>
>>>>  from_env = {'a': 12}
>>>>  from_config = {'a': 13}
>>>>
>>>>  f(**from_env, **from_config)
>>>>
>>>> I would think 'a' should be 13, as from_config is processed /after/ from_env.
>>>>
>>>> So which is it?
>>>
>>> In the face of ambiguity, refuse the temptation to guess.
>>
>> Lots of things are ambiguous until one learns the rules.  ;)
> 
> I don't see why `f(**{'a': 12}, **{'a': 13})` should not be equivalent
> to `f(a=12, **{'a':13})` – iow, raise TypeError.

It destroy's the chaining value and pretty much makes the improvement not an improvement.  If there's a possibility that
the same key could be in more than one of the dictionaries then you still have to do the

  dict.update(another_dict)

dance.

--
~Ethan~

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150126/c2779497/attachment.sig>


More information about the Python-Dev mailing list