-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
bpo-31504: Update stdtypes.rst #3642
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
Conversation
Added behaviour of `find` when `substring` is `""`.
Hi @kgashok , Build is failing as this is not true:
|
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.
Thanks for your contribution.
Your PR has multiple issues:
- Title of the ticket is not recognized by our bot. You need to add a colon after the bpo number:
bpo-31504: Update stdtypes.rst
- Doc tests are failing. You added extra line.
- As @raulcd already pointed out, the patch is wrong.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@@ -1583,6 +1583,12 @@ expression support in the :mod:`re` module). | |||
>>> 'Py' in 'Python' | |||
True | |||
|
|||
If the substring *sub* is ``''``, then `:meth:~str.find` method will return | |||
a value that is equal to ``len(str)``. |
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 the text should explain why. As shows in the bpo-24243 ticket, people may be surprised by this behaviour if they don’t understand how it derives from Python’s notion of string slices. If you know that '' in 'abc'
is true + the doc of str.find says it returns the highest index of the found substring, then this is not a surprise. I am not sure that mentioning len
only here will help people make sense of it.
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.
Notation note: let’s write code like len(s)
, not len(str)
.
Closed because tests failed, the added claim is not true, and the author is not active for a half of year. |
Added behaviour of
find
whensubstring
is""
.https://bugs.python.org/issue31504