[docs] [issue31504] Documentation for return value for string.rindex is missing when search string is empty
R. David Murray
report at bugs.python.org
Mon Sep 18 11:55:59 EDT 2017
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 <weird example> of something'
>>> x.rfind('>', 9)
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 <report at bugs.python.org>
More information about the docs