Skip to content

Commit

Permalink
Show example of itemgetter() applied to a dictionary (#3431)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhettinger committed Sep 8, 2017
1 parent 8e0ad46 commit 70c2dd3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Doc/library/operator.rst
Expand Up @@ -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:
Expand Down

0 comments on commit 70c2dd3

Please sign in to comment.