[Python-ideas] Allow using ** twice

yoav glazner yoavglazner at gmail.com
Fri Jun 7 12:27:48 CEST 2013


On Jun 7, 2013 1:08 PM, "Serhiy Storchaka" <storchaka at gmail.com> wrote:
>
> 07.06.13 10:31, Steven D'Aprano написав(ла):
>
>> At this point, I'd begin to think of a built-in updated function. Here's
>> one possible implementation, slightly different from yours below:
>>
>> def updated(*mappings, **kw):
>>      new = {}
>>      for mapping in mappings + (kw,):
>>          new.update(mapping)
>>      return new
>
>
> Or
>
> def updated(*mappings, **kw):
>     from collections import ChainMap
>     return ChainMap((kw,) + mappings[::-1])
>
>
>> Given how trivial is it, I'm not sure it's even worthwhile. But then,
>> prior to sorted and reversed being added as built-ins, people argued
>> that they were "too trivial" too. On the third hand, the existence of
>> two, or more, implementations with subtly different semantics is an
>> argument on picking the most useful version and putting it in the
>> standard library.
>>
>> So I'm now +0 for a built-in updated and +0.5 for collections.updated.
>
>
> I'm -1 for both. The collections module already contains an appropriate
tool. And if ChainMap() is not a builtin, why updated() should be?
>
ChainMap does not return a copy its a view
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130607/e3070e01/attachment.html>


More information about the Python-ideas mailing list