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

This commit is contained in:
Raymond Hettinger 2017-09-07 23:53:07 -07:00 committed by GitHub
parent 8e0ad46bc8
commit 70c2dd306f
1 changed files with 3 additions and 0 deletions

View File

@ -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: