[doc] Remove duplicated operator.itemgetter example (GH-24178)

* Remove duplicated itemgetter example
* Add spaces
This commit is contained in:
Andre Delfino 2021-04-27 01:15:31 -03:00 committed by GitHub
parent 9dfefbe3e2
commit 743e2bae10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -319,15 +319,12 @@ expect a function argument.
method. Dictionaries accept any hashable value. Lists, tuples, and method. Dictionaries accept any hashable value. Lists, tuples, and
strings accept an index or a slice: strings accept an index or a slice:
>>> itemgetter('name')({'name': 'tu', 'age': 18})
'tu'
>>> itemgetter(1)('ABCDEFG') >>> itemgetter(1)('ABCDEFG')
'B' 'B'
>>> itemgetter(1,3,5)('ABCDEFG') >>> itemgetter(1, 3, 5)('ABCDEFG')
('B', 'D', 'F') ('B', 'D', 'F')
>>> itemgetter(slice(2,None))('ABCDEFG') >>> itemgetter(slice(2, None))('ABCDEFG')
'CDEFG' 'CDEFG'
>>> soldier = dict(rank='captain', name='dotterbart') >>> soldier = dict(rank='captain', name='dotterbart')
>>> itemgetter('rank')(soldier) >>> itemgetter('rank')(soldier)
'captain' 'captain'