[issue11842] slice.indices with negative step and default stop

2012-11-04 Thread Mark Dickinson

Mark Dickinson added the comment:

Agreed.  Closing.

--
resolution:  -> invalid
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11842] slice.indices with negative step and default stop

2012-11-03 Thread Mark Lawrence

Mark Lawrence added the comment:

I think this should be closed as slice.indices behaves exactly as I expect it 
to, and the returned values are for any sequence and not just range().

--
nosy: +BreamoreBoy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11842] slice.indices with negative step and default stop

2011-11-19 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
stage:  -> needs patch
versions: +Python 2.7, Python 3.3 -Python 3.1

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11842] slice.indices with negative step and default stop

2011-04-14 Thread Daniel Urban

Daniel Urban  added the comment:

I see. Thanks for the explanation. If indeed this is the expected behaviour (as 
it seems), then I suggest clarifying the documentation. I think it would be 
good to mention that the returned values are for range(), and not for creating 
another slice object.

--
assignee:  -> docs@python
components: +Documentation -Interpreter Core
nosy: +docs@python

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11842] slice.indices with negative step and default stop

2011-04-13 Thread João Sebastião de Oliveira Bueno

João Sebastião de Oliveira Bueno  added the comment:

I don't see this as a bug. The indices returned in both cases are exactly what 
you need to feed to range, in order to get the correct indices for the provided 
slice parameters.

Perceive that if for 
s = slice(None, None, -2)

It would return anything different from
(9, -1, -2)
It would be impossible to properly generate the desired indices. (With a 0 
instead of -1, we would be missing the last index).

When you pass these numbers with the "[" "]" notation for being used as 
indices, the negative index is interpreted as "len(sequence) - index". In the 
case of "-1" in your example it is the same as "9" not the same as "one before 
zero".

I recommend closing this as not a bug.

--
nosy: +João.Sebastião.de.Oliveira.Bueno

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11842] slice.indices with negative step and default stop

2011-04-13 Thread Daniel Urban

New submission from Daniel Urban :

slice.indices behaves strangely with negative step and default stop values 
(note that the doc says that it "computes information about the slice that the 
slice object would describe if applied to a sequence of length items"):

>>> s = slice(None, None, -2)
>>> s.indices(10)
(9, -1, -2)
>>> list(range(10))[9:-1:-2]
[]
>>> list(range(10))[s]
[9, 7, 5, 3, 1]
>>> 

Also with start given:

>>> s = slice(8, None, -2)
>>> s.indices(10)
(8, -1, -2)
>>> list(range(10))[8:-1:-2]
[]
>>> list(range(10))[s]
[8, 6, 4, 2, 0]
>>> 

Strangely giving these indices to range works:

>>> s = slice(8, None, -2)
>>> s.indices(10)
(8, -1, -2)
>>> list(range(8, -1, -2))
[8, 6, 4, 2, 0]
>>>

--
components: Interpreter Core
messages: 133694
nosy: durban, mark.dickinson
priority: normal
severity: normal
status: open
title: slice.indices with negative step and default stop
type: behavior
versions: Python 3.1, Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com