This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tttnns
Recipients rhettinger, serhiy.storchaka, tttnns
Date 2018-03-12.09:20:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1520846443.21.0.467229070634.issue33040@psf.upfronthosting.co.za>
In-reply-to
Content
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()
History
Date User Action Args
2018-03-12 09:20:43tttnnssetrecipients: + tttnns, rhettinger, serhiy.storchaka
2018-03-12 09:20:43tttnnssetmessageid: <1520846443.21.0.467229070634.issue33040@psf.upfronthosting.co.za>
2018-03-12 09:20:43tttnnslinkissue33040 messages
2018-03-12 09:20:42tttnnscreate