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 misianne
Recipients misianne
Date 2020-11-25.20:54:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1606337661.06.0.654642127073.issue42467@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-11-25 20:54:21misiannesetrecipients: + misianne
2020-11-25 20:54:21misiannesetmessageid: <1606337661.06.0.654642127073.issue42467@roundup.psfhosted.org>
2020-11-25 20:54:21misiannelinkissue42467 messages
2020-11-25 20:54:21misiannecreate