Skip to content

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

Closed
wants to merge 1 commit into from
Closed

Conversation

kgashok
Copy link

@kgashok kgashok commented Sep 18, 2017

Added behaviour of find when substring is "".

https://bugs.python.org/issue31504

Added behaviour of `find` when `substring` is `""`.
@kgashok kgashok changed the title Update stdtypes.rst bpo-31504 Update stdtypes.rst Sep 18, 2017
@raulcd
Copy link
Contributor

raulcd commented Sep 21, 2017

Hi @kgashok ,

Build is failing as this is not true:

Python 3.6.2 (default, Aug 23 2017, 13:37:24) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 'abc'.find('')
0

Copy link
Member

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

@bedevere-bot
Copy link

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 I didn't expect the Spanish Inquisition!. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@@ -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)``.
Copy link
Member

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.

Copy link
Member

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

@kgashok kgashok changed the title bpo-31504 Update stdtypes.rst bpo-31504: Update stdtypes.rst Sep 21, 2017
@serhiy-storchaka
Copy link
Member

Closed because tests failed, the added claim is not true, and the author is not active for a half of year.

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.

7 participants