TitanSnow <tttnns1...@gmail.com> added the comment: Now I have thought about it and realized that it's not suitable for islice. But there's still a common use case to drop some elements from the beginning or ending of a iterable, which is also a main reason why I wanted islice to support negative values of start and stop. So how about adding two functions ``drop_first`` and ``drop_last`` to do such things. They can be implemented like this, in which way they support arbitrary iterators::
def drop_first(iterable, n=1): for _ in range(n): next(iterable) for e in iterable: yield e def drop_last(iterable, n=1): dq = deque() for _ in range(n): dq.append(next(iterable)) for e in iterable: dq.append(e) yield dq.popleft() ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33040> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com