[Python-ideas] New list methods

Steven D'Aprano steve at pearwood.info
Wed May 6 08:03:50 CEST 2009


On Wed, 6 May 2009 02:27:18 pm Terry Reedy wrote:
> Carl Johnson wrote:
> > Would there be any interest in adding a 'reversed' kwarg to the
> > relevant string methods, deprecating the r-methods in Python 3.2,
> > and removing them in Python 3.3? It might make things a little
> > simpler and unclutter the dir for strings a bit…
>
> I personally would strongly prefer a reverse keyward and would not
> mind de-cluttering the current set of methods too.

Do you have any use-cases where you don't know whether you want 
forward or reverse search until runtime?

That is, where you currently write something like:

if some_var:
    n = astring.find(target)
else:
    n = astring.rfind(target)

or equivalent?

-- 
Steven D'Aprano 



More information about the Python-ideas mailing list