[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2020-10-31 Thread Vedran Čačić
Vedran Čačić added the comment: Maybe you would use 5, but I would use 7 and get the same result. If the docs say "X.rindex(Y) == i means i is the highest index where Y is found in X", and "Y is found in X at i" is interpreted as "X[i:i+len(Y)] == Y" (as Serhiy said), then there is no such (h

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2020-10-31 Thread Irit Katriel
Change by Irit Katriel : -- resolution: -> rejected stage: patch review -> resolved status: pending -> closed type: enhancement -> behavior ___ Python tracker ___

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2018-03-26 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- status: open -> pending ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread R. David Murray
R. David Murray added the comment: You have to remember that the most useful way to think about python slice indexes is that they point between characters. Consider, for example, that you have a starting index of something, and you are looking backward in the string for a trailing delimiter:

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Vedran Čačić
Vedran Čačić added the comment: This is nonsense. 'abcde'[7:7] is also ''. So the maximal index in fact doesn't exist. What do you think exactly is the property that differentiates 5 from 7 here? -- nosy: +veky ___ Python tracker

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Ashok Bakthavathsalam
Changes by Ashok Bakthavathsalam : -- type: behavior -> enhancement ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscr

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Ashok Bakthavathsalam
Ashok Bakthavathsalam added the comment: @Storchaka, You say `5` is related to the substring. Pray, explain how 5 is related to a null substring? Also, from https://bugs.python.org/msg243710, as per the great Hettinger: Though this is closed as not a bug, feel free to add an example or a

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Ashok Bakthavathsalam
Ashok Bakthavathsalam added the comment: Look at my suggested changes. It doesn't add noise, IMHO. All I am saying is that the explicit behaviour needs to be documented. I unnecessarily wasted at least 3-4 hours on this "undocumented" behavior. -- _

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: 5 is not valid index of character, but it is valid index of substring. IMHO documenting explicitly miscellaneous particular cases which are not exceptions of general rules just adds a noise. This makes the documentation larger and decrease the chance that it

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Ashok Bakthavathsalam
Ashok Bakthavathsalam added the comment: How about "abcde"[5] Traceback (most recent call last): File "python", line 1, in IndexError: string index out of range -- ___ Python tracker _

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Ashok Bakthavathsalam
Ashok Bakthavathsalam added the comment: I am not saying that there is a bug. As Martin points out, "it is worth making the documentation explicit." -- ___ Python tracker ___ _

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The documentation doesn't mention empty string specially because there is nothing special with empty string. Returned index value is valid. "abcde"[5:5] == "". Issue24243 is about the case of end < start. Not this case. I don't see a bug here. --

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Ashok Bakthavathsalam
Changes by Ashok Bakthavathsalam : -- keywords: +patch pull_requests: +3637 stage: -> patch review ___ Python tracker ___ ___ Python

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Martin Panter
Martin Panter added the comment: The behaviour for searching for empty strings in Python is inconsistent; see Issue 24243. IMO the behaviour for the (r)find/index methods is sensible, but it is worth making the documentation explicit. The returned indexes you have given (5, 1, and 0) are valid

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Ashok Bakthavathsalam
Ashok Bakthavathsalam added the comment: The documentation (https://docs.python.org/3/library/stdtypes.html#str.find) does not describe what will be the behaviour if the substring is "". And by the way, as per https://docs.python.org/3/reference/expressions.html#membership-test-operations,

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This is documented. "Return the highest index in the string where substring sub is found," -- nosy: +serhiy.storchaka ___ Python tracker ___

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Ashok Bakthavathsalam
Ashok Bakthavathsalam added the comment: string.find() also exhibits the same behaviour. "abcde".find("") -> 5 which also is not documented anywhere. -- ___ Python tracker ___

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Ashok Bakthavathsalam
Ashok Bakthavathsalam added the comment: Also, "".rindex("") returns 0 -- ___ Python tracker ___ ___ Python-bugs-list mailing list Un

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Ashok Bakthavathsalam
Changes by Ashok Bakthavathsalam : -- assignee: -> docs@python components: +Documentation -Library (Lib) nosy: +docs@python ___ Python tracker ___ _

[issue31504] Documentation for return value for string.rindex is missing when search string is empty

2017-09-18 Thread Ashok Bakthavathsalam
New submission from Ashok Bakthavathsalam: "abcde".rindex("") returns 5 "a".rindex("") returns 1 This is not documented anywhere in the Python documentation. -- components: Library (Lib) messages: 302418 nosy: kgashok priority: normal severity: normal status: open title: Documentation