-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
itemgetter add dict example #1280
Conversation
@twz915, thanks for your PR! By analyzing the history of the files in this pull request, we identified @birkenfeld, @benjaminp and @tiran to be potential reviewers. |
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA. This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
@@ -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}) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
I think existing words are enough for explaining |
@twz915: Hi, would you mind to open a bug on bugs.python.org and sign the CLA please? Otherwise, we will be unable to accept your contribution and will have to close your PR :-( |
I think that this qualifies at the upper edge of trivial, so that no issue or CLA is needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Bitdancer that this fits nicely at the proposed location. The itemgetter concept is not initially trivial and I think that this helps a bit. If not for other opinions, I would merge it.
@terryjreedy That's why I added the snippet. I think it is a good example to help users to understand |
@Haypo I don't think this is a bug, and add the example is just used to contribute a better understanding. |
@twz915 Some people say 'bug' when they really mean 'issue'. The issues on the site include enhancement requests and performance improvements. The site could have been called 'issues/python/org' or 'tracker/python/org', but someone named it 'bugs/python/org'. |
The other interpretation is that a 'bug' is a report of something that 'bugs' the person who opens the issue. You were 'bugged' by the absence of a mapping example. Once an issue is open, we carefully classify it as about (bad) behavior, enhancement, performance, security, or something else. |
Sorry, I requested an issue before reading the PR. I read your PR, I agree that no issue is required here. |
Since this is such a trivial change, I have merged it. Thanks, @twz915, for your contribution. Please fill out the contributor form for any future contributions. |
The document says that
operator.itemgetter
using the operand’s__getitem__()
method. However, it is difficult to understand for a newbie.One example is better than thousands of words.