
On Tue, May 5, 2009 at 7:31 PM, Steven D'Aprano <steve@pearwood.info> wrote:
On Wed, 6 May 2009 06:20:31 am 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…
A "reversed" kwarg would only be useful when you don't know which direction you want to search in until runtime. How often does that happen? In practice, I believe you will nearly always know whether you want to search from the left or the right when you're writing the code. so I expect the "reversed" kwarg will nearly always be given as a constant:
astring.find("spam", reversed=True)
as opposed to:
astring.find("spam", reversed=(today==Wednesday))
A slightly whimsical example, but I hope it illustrates the point.
Sorry, that doesn't make much sense. Not only list.sort()/sorted() use exactly this API and we (thankfully) don't have list.rsort()/rsorted(), but that argument could be used against almost all functions with boolean parameters, since they are typically called with a constant True or False [1]. George [1] http://www.google.com/codesearch?hl=en&start=10&sa=N&filter=0p&q=lang:python+package:svn.python.org/projects/python/trunk+%3D(True|False)