New submission from misianne <rote...@gmail.com>:
I have a problem with slice().indices(): x=[0,1,2,3,4,5,6,7,8,9]*10 x[-91:-101:-3] # == [9, 6, 3, 0] OK! x[slice(*slice(-91,-101,-3).indices(len(x)))] # == [] WRONG! This is correct: x[-91:-100:-3] # == [9, 6, 3] OK! x[slice(*slice(-91,-100,-3).indices(len(x)))] # == [9, 6, 3] OK! This is not: x[-91:-101:-3] # == [9, 6, 3, 0] OK! x[slice(*slice(-91,-101,-3).indices(len(x)))] # == [] WRONG! The problem is that slice(-91,-101,-3).indices(len(x)) returns: (9,-1,-3) which result in an empty list, while: (9,None,-3) gives the correct result. ---------- components: Interpreter Core messages: 381862 nosy: misianne priority: normal severity: normal status: open title: slice().indices() returns incorrect values versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42467> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com