This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dtorp
Recipients dtorp
Date 2010-04-27.22:20:19
SpamBayes Score 0.012059351
Marked as misclassified No
Message-id <1272406821.86.0.455746879552.issue8551@psf.upfronthosting.co.za>
In-reply-to
Content
The purpose of the start argument in str.find() and str.rfind() is to allow for repeated searches.  

>>> def find_third_occurrence(s, value):
...	p = s.find(value)
...	p = s.find(value, p+1)
...	return s.find(value, p+1)
...
>>> find_third_occurrence('scientific american', 'c')
16

The rfind() method is meant for searching from the right, but its start argument is used internally as if it were searching from the left.  This bug makes it useless for repeated searches from the right.

>>> 'scientific american'.rfind('c')
16
>>> 'scientific american'.rfind('c', 15)
16
>>> 'scientific american'.rfind('c', 14)
16

Having found the first 'c' from the right at position 16, there is no way to tell it to search further from the right and find the second 'c' at position 9.
History
Date User Action Args
2010-04-27 22:20:22dtorpsetrecipients: + dtorp
2010-04-27 22:20:21dtorpsetmessageid: <1272406821.86.0.455746879552.issue8551@psf.upfronthosting.co.za>
2010-04-27 22:20:20dtorplinkissue8551 messages
2010-04-27 22:20:19dtorpcreate