6 Oct
2011
6 Oct
'11
5:42 p.m.
On Thu, 2011-10-06 at 17:47 +0200, Jan Kaliszewski wrote:
A lightweight builtin type whose instances would have `index` attribute might do the job well (together with None as not-found).
A naive pure-Python implementation:
class Found(object): __slots__ = 'index', def __init__(self, index): self.index = index
... found = s.search(one_of) ...
It seems to me, the methods on the string object should be the lower level fast C methods that allow for efficient higher level functions to be built. A search class may be a good addition to string.py. It already has higher order stuff for composing strings, format and template, but nothing for decomposing strings. Cheers, Ron