Serge Orlov wrote: > Peter Otten wrote: >> Gary Wessle wrote: >> >> >> These days str methods are preferred over the string module's >> >> functions. >> >> >> >> >>> text = "abc abc and Here and there" >> >> >>> here_pos = text.find("Here") >> >> >>> text.rfind("abc", 0, here_pos) >> >> 4 >> >> >> >> Peter >> > >> > and what about when python 3.0 is released and those depreciated >> > functions like find and rfind are not supported. is there another >> > solution which is more permanent? >> >> I think the functions may go away, the methods will stay; so I'm >> confident the above will continue to work. > > find and rfind methods are in danger too. AFAIR they are to be replaced > by partion and rpartition methods. People who are worried about future > can continue to use index and rindex
I really should read those PEPs before posting. And just as I was starting to complain I noted that my original reply to Gary is buggy -- excluding the last letter in the string from the rfind() search if "Here" is not found is probably never the desired behaviour. So r/index() is indeed superior here. Peter -- http://mail.python.org/mailman/listinfo/python-list