mirror of https://github.com/python/cpython
Show example of itemgetter() applied to a dictionary (#3431)
This commit is contained in:
parent
8e0ad46bc8
commit
70c2dd306f
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue