Skip to content
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

Merged
merged 1 commit into from
Apr 13, 2018
Merged

itemgetter add dict example #1280

merged 1 commit into from
Apr 13, 2018

Conversation

twz915
Copy link

@twz915 twz915 commented Apr 25, 2017

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.

@mention-bot
Copy link

@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.

@the-knights-who-say-ni
Copy link

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})
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.

@serhiy-storchaka
Copy link
Member

I think existing words are enough for explaining operator.itemgetter. Open an issue on the bug tracker for discussion.

@vstinner
Copy link
Member

@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 :-(

@terryjreedy
Copy link
Member

I think that this qualifies at the upper edge of trivial, so that no issue or CLA is needed.
Brett, do we have a specific rule on number of characters or words?
That mean this is also at the upper edge of what does not need a Misc/ACK entry.

Copy link
Member

@terryjreedy terryjreedy left a 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.

@twz915
Copy link
Author

twz915 commented Jul 25, 2017

@terryjreedy That's why I added the snippet. I think it is a good example to help users to understand itemgetter and list's List[x] or dict's Dict[x] behavior better.

@twz915
Copy link
Author

twz915 commented Jul 25, 2017

@Haypo I don't think this is a bug, and add the example is just used to contribute a better understanding.

@terryjreedy
Copy link
Member

@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'.

@terryjreedy
Copy link
Member

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.

@vstinner
Copy link
Member

Sorry, I requested an issue before reading the PR. I read your PR, I agree that no issue is required here.

@ned-deily
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.