[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 (highest) index.

I understand what _you_'re saying, but please understand that the docs do not 
say anything like that.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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:

  >>> x = 'this is  of something'
  >>> x.rfind('>', 9)
  22
  >>> x[9:22]
  'weird example'

So the above is why 5 is different from 7: 5 is the index that you would use in 
a slice if you wanted the string that ended before the match...and the match in 
the null string case is the end of the string.  That is, Python is being 
consistent in this degenerate case.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 
   mention in the documentation.  Keep it short though.  

That's all I am asking to be included.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 will be read.

--
nosy: +r.david.murray, rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 for slicing.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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,
 

Empty strings are always considered to be a substring of any other 
string, so "" in "abc" will return True.

Returning an invalid index value, although confusing, should at least be 
documented in some form.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 for return value for string.rindex is missing when search 
string is empty
type: behavior
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com