[Python-ideas] What are the strong use cases for str.rindex()?

林自均 johnlinp at gmail.com
Tue Apr 23 02:44:25 EDT 2019

Hi all,

I found that there are str.index() and str.rindex(), but there is only
list.index() and no list.rindex(). So I filed the issue
https://bugs.python.org/issue36639 to provide list.rindex(). However, the
issue was rejected and closed with the comment:

> There were known, strong use cases for str.rindex().  The list.rindex()
method was intentionally omitted.  AFAICT no compelling use cases have
arisen, so we should continue to leave it out.  In general, we don't grow
the core APIs unnecessarily.

However, I am not sure what the known, strong use cases for str.rindex()
are. Why doesn't the strong use cases apply on list.rindex()? Could anyone
give me some examples? Thanks.

John Lin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190423/fe3735b8/attachment.html>

More information about the Python-ideas mailing list