[issue33040] Make itertools.islice supports negative values for start and stop arguments for sized iterable object

2021-04-28 Thread Yaroslav Nikitenko
Yaroslav Nikitenko added the comment: Sorry for a typo. The paragraph before the last should read Negative *step* fundamentally changes the algorithm:... flow[-1:None:-1]. -- ___ Python tracker

[issue33040] Make itertools.islice supports negative values for start and stop arguments for sized iterable object

2021-04-28 Thread Yaroslav Nikitenko
Yaroslav Nikitenko added the comment: I hope it's fine to add to closed topics here. I agree with the decision that islice should not handle a special case of sized containers vs iterables. However, I think that the support of negative indices in islice would be nice. A simple use case

[issue33040] Make itertools.islice supports negative values for start and stop arguments for sized iterable object

2018-03-12 Thread TitanSnow
TitanSnow 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

[issue33040] Make itertools.islice supports negative values for start and stop arguments for sized iterable object

2018-03-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: I concur with Serhiy. This doesn't make sense for itertools. Marking this as closed. Thank you for the suggestion. -- resolution: -> rejected stage: -> resolved status: open -> closed

[issue33040] Make itertools.islice supports negative values for start and stop arguments for sized iterable object

2018-03-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I do not think this is suitable for the itertools module. It is designed to work with iterators, i.e. with objects that support the iterator protocol. What if the iterable change the size during iteration? Should the islice

[issue33040] Make itertools.islice supports negative values for start and stop arguments for sized iterable object

2018-03-10 Thread TitanSnow
New submission from TitanSnow : ``islice()`` does not support negative values for start or stop, which does not matter for plain iterators. However, for some cases, we have a sized iterable object which is not subscriptable, using ``islice()`` makes code ugly:: d =