summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorWeizhongTu <tuweizhong@163.com>2018-04-13 01:33:08 (GMT)
committerNed Deily <nad@python.org>2018-04-13 01:33:08 (GMT)
commitffa2c3e2c40acae07aca5b77f2c0e8c14a00438d (patch)
treeb3d6824108d6f52869704223979f5813b3066865 /Doc
parent04e82934659487ecae76bf4a2db7f92c8dbe0d25 (diff)
downloadcpython-ffa2c3e2c40acae07aca5b77f2c0e8c14a00438d.zip
cpython-ffa2c3e2c40acae07aca5b77f2c0e8c14a00438d.tar.gz
cpython-ffa2c3e2c40acae07aca5b77f2c0e8c14a00438d.tar.bz2
itemgetter add dict example (GH-1280)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/operator.rst2
1 files changed, 2 insertions, 0 deletions
diff --git a/Doc/library/operator.rst b/Doc/library/operator.rst
index e4d6d05..250cbb6 100644
--- a/Doc/library/operator.rst
+++ b/Doc/library/operator.rst
@@ -315,6 +315,8 @@ expect a function argument.
method. Dictionaries accept any hashable value. Lists, tuples, and
strings accept an index or a slice:
+ >>> itemgetter('name')({'name': 'tu', 'age': 18})
+ 'tu'
>>> itemgetter(1)('ABCDEFG')
'B'
>>> itemgetter(1,3,5)('ABCDEFG')