
5 Jun
2014
5 Jun
'14
12:39 a.m.
05.06.14 03:03, Greg Ewing написав(ла):
Serhiy Storchaka wrote:
html.HTMLParser, json.JSONDecoder, re.compile, tokenize.tokenize don't use iterators. They use indices, str.find and/or regular expressions. Common use case is quickly find substring starting from current position using str.find or re.search, process found token, advance position and repeat.
For that kind of thing, you don't need an actual character index, just some way of referring to a place in a string.
Of course. But _existing_ Python interfaces all work with indices. And it is too late to change this, this train was gone 20 years ago.
There is no need in yet one way to do string operations. One obvious way is enough.