[Python-checkins] itemgetter add dict example (GH-1280)
Ned Deily
webhook-mailer at python.org
Thu Apr 12 21:33:12 EDT 2018
https://github.com/python/cpython/commit/ffa2c3e2c40acae07aca5b77f2c0e8c14a00438d
commit: ffa2c3e2c40acae07aca5b77f2c0e8c14a00438d
branch: master
author: WeizhongTu <tuweizhong at 163.com>
committer: Ned Deily <nad at python.org>
date: 2018-04-12T21:33:08-04:00
summary:
itemgetter add dict example (GH-1280)
files:
M Doc/library/operator.rst
diff --git a/Doc/library/operator.rst b/Doc/library/operator.rst
index e4d6d05a23a7..250cbb6b7c07 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')
More information about the Python-checkins
mailing list