[issue23086] Add start and stop parameters to the Sequence.index() ABC mixin method

Raymond Hettinger report at bugs.python.org
Thu Jan 8 10:46:16 CET 2015


Raymond Hettinger added the comment:

Try something like this:

        if start < 0:
            start += len(self)
        if stop is None:
            stop = len(self)
        elif stop < 0:
            stop += len(self)
        for i in range(max(start, 0), min(stop, len(self))):
            if self[i] == value:
                return i
        raise ValueError

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23086>
_______________________________________


More information about the Python-bugs-list mailing list