Author r.david.murray
Recipients docs@python, kgashok, martin.panter, r.david.murray, rhettinger, serhiy.storchaka, veky
Date 2017-09-18.15:55:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1505750159.78.0.637863599728.issue31504@psf.upfronthosting.co.za>
In-reply-to
Content
You have to remember that the most useful way to think about python slice indexes is that they point between characters. Consider, for example, that you have a starting index of something, and you are looking backward in the string for a trailing delimiter:

  >>> x = 'this is <weird example> of something'
  >>> x.rfind('>', 9)
  22
  >>> x[9:22]
  'weird example'

So the above is why 5 is different from 7: 5 is the index that you would use in a slice if you wanted the string that ended before the match...and the match in the null string case is the end of the string.  That is, Python is being consistent in this degenerate case.
History
Date User Action Args
2017-09-18 15:55:59r.david.murraysetrecipients: + r.david.murray, rhettinger, docs@python, martin.panter, serhiy.storchaka, veky, kgashok
2017-09-18 15:55:59r.david.murraysetmessageid: <1505750159.78.0.637863599728.issue31504@psf.upfronthosting.co.za>
2017-09-18 15:55:59r.david.murraylinkissue31504 messages
2017-09-18 15:55:59r.david.murraycreate