[Python-checkins] Show example of itemgetter() applied to a dictionary (#3431)

Raymond Hettinger webhook-mailer at python.org
Fri Sep 8 02:53:09 EDT 2017


https://github.com/python/cpython/commit/70c2dd306f575e8bc9edb10ced5c7a6a555d1c87
commit: 70c2dd306f575e8bc9edb10ced5c7a6a555d1c87
branch: master
author: Raymond Hettinger <rhettinger at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2017-09-07T23:53:07-07:00
summary:

Show example of itemgetter() applied to a dictionary (#3431)

files:
M Doc/library/operator.rst

diff --git a/Doc/library/operator.rst b/Doc/library/operator.rst
index 8121b480cb6..76335b179c5 100644
--- a/Doc/library/operator.rst
+++ b/Doc/library/operator.rst
@@ -321,6 +321,9 @@ expect a function argument.
       >>> itemgetter(slice(2,None))('ABCDEFG')
       'CDEFG'
 
+      >>> soldier = dict(rank='captain', name='dotterbart')
+      >>> itemgetter('rank')(soldier)
+      'captain'
 
    Example of using :func:`itemgetter` to retrieve specific fields from a
    tuple record:



More information about the Python-checkins mailing list