-
-
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
bpo-31942: Document optional support of start and stop attributes in Sequence.index method #4277
Conversation
@serhiy-storchaka: Would you mind to review this PR, since you worked on that topic and created https://bugs.python.org/issue31942 ? |
Lib/_collections_abc.py
Outdated
@@ -899,6 +899,10 @@ def __reversed__(self): | |||
def index(self, value, start=0, stop=None): | |||
'''S.index(value, [start, [stop]]) -> integer -- return first index of value. | |||
Raises ValueError if the value is not present. | |||
|
|||
It is not required that all concrete implementations of | |||
the Sequence class support start and stop attributes. |
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 would rephrase it as:
Supporting start and stop optional arguments is optional, but recommended.
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 changed it to 'Supporting start and stop arguments is optional, but recommended.". I removed the first 'optional' word because the senses of both 'optional' words is different and might confuse the reader and also the sense of first 'optional' is conveyed by the function signature anyway.
Doc/library/stdtypes.rst
Outdated
without copying any data and with the returned index being relative to | ||
the start of the sequence rather than the start of the slice. | ||
Not all implementations support passing the additional arguments *i* and *j*. | ||
When supported, these arguments allow efficient searching of |
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.
"Not all implementations support passing the additional arguments i and j." seems redundant with "When supported".
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.
Done.
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.
LGTM.
Doc/library/stdtypes.rst
Outdated
the start of the sequence rather than the start of the slice. | ||
Not all implementations support passing the additional arguments | ||
*i* and *j*. These arguments allow efficient searching of | ||
subsections of the sequence. Passing the extra arguments is roughly |
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.
Avoid reflowing the lines that are not changed.
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.
Minimised the reflowing.
Lib/_collections_abc.py
Outdated
|
||
Supporting start and stop arguments is optional, but | ||
recommended. | ||
|
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.
Redundant empty line.
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.
Removed it.
…Sequence.index method (pythonGH-4277) (cherry picked from commit 5ce0a2a)
GH-4811 is a backport of this pull request to the 3.6 branch. |
I changed the method docstring and also the html documentation to say that not all implementations are required to support start and stop attributes. Is a NEWS entry required for this?
Bug: https://bugs.python.org/issue31942
https://bugs.python.org/issue31942