Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Doc/library/operator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,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})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this shouldn't put here, this code block is for explaining Lists, tuples, and strings accept an index or a slice:, not Dictionaries accept any hashable value.

If we want to add a new example for dictionaries, it should make a new code block above this one.

Copy link
Member

@bitdancer bitdancer Apr 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this makes the example exactly parallel the paragraph it follows, showing the dictionary example first, then the index, and then the slice, in the order they are mentioned in the text. Breaking the paragraph up with the example would not improve the flow, in my opinion. The fact that dictionary is in a separate sentence doesn't matter that much, I think.

'tu'
>>> itemgetter(1)('ABCDEFG')
'B'
>>> itemgetter(1,3,5)('ABCDEFG')
Expand Down