New submission from David Albert Torpey <dt...@users.sourceforge.net>:
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. ---------- components: Interpreter Core messages: 104375 nosy: dtorp priority: normal severity: normal status: open title: Start argument for str.rfind used incorrectly type: behavior versions: Python 2.6, Python 3.1 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8551> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com