A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-November/150482.html below:

[Python-Dev] Analog of PEP 448 for dicts (unpacking in assignment with dict rhs)

[Python-Dev] Analog of PEP 448 for dicts (unpacking in assignment with dict rhs)Serhiy Storchaka storchaka at gmail.com
Sun Nov 12 10:43:53 EST 2017
12.11.17 12:06, Nick Coghlan пише:
> So if folks would like dict unpacking syntax, then a suitable place to
> start would be a proposal for a "getitems"  builtin that allowed
> operations like:
> 
>      b, a  = getitems(d, ("b", "a"))
> 
> operator.itemgetter and operator.attrgetter may provide some
> inspiration for possible proposals.

I don't see any relations between this getitems and operator.itemgetter 
or operator.attrgetter. getitems can be implemented as:

(the most obvious way)

     def getitems(mapping, keys):
         for key in keys:
             yield mapping[key]

or

     def getitems(mapping, keys):
         return map(functools.partial(operator.getitem, mapping), keys)

or (simpler but rough equivalent)

     def getitems(mapping, keys):
         return map(mapping.__getitem__, keys)

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4