[Python-bugs-list] [ python-Bugs-684022 ] extended slice strangeness

SourceForge.net noreply@sourceforge.net
Mon, 10 Feb 2003 09:12:24 -0800


Bugs item #684022, was opened at 2003-02-10 11:54
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=684022&group_id=5470

Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Robert Roy (rjroy)
>Assigned to: Michael Hudson (mwh)
Summary: extended slice strangeness

Initial Comment:
I was playing with extended slices and wanted to see if 
it would return a reversed slice. The behaviour was not 
quite what I expected. See the following


Python 2.3a1 (#38, Dec 31 2002, 17:53:59) [MSC 
v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more 
information.
>>> l = range(12)
>>> l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
## this works as expected
>>> l[0:5:2]
[0, 2, 4]

## this returns empty list ??
>>> l[0:5:-1]
[]

## this works as expected
>>> l[::-1]
[11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

## I would expect this to return same as above
>>> l[0::-1]
[0]

## would expect empty list since l[5:0] == []
>>> l[5:0:-1]
[5, 4, 3, 2, 1]

## would expect [11, 10, 9, 8, 7, 6,5]
>>> l[5::-1]
[5, 4, 3, 2, 1, 0]
>>>


----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-02-10 12:12

Message:
Logged In: YES 
user_id=33168

I'm not sure what I would expect.  Your suggestions seem
reasonable.  Michael?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=684022&group_id=5470