Mensanator wrote:
On Mar 5, 6:34 pm, Gary Herron wrote:
Mensanator wrote:
On Mar 5, 3:42 pm, Gary Herron wrote:
Mensanator wrote:
The only way to get a 0 from a reverse range() is to have a bound of
-1.
Not quite. An empty second bound goes all the way t
On Mar 5, 6:34 pm, Gary Herron wrote:
> Mensanator wrote:
> > On Mar 5, 3:42 pm, Gary Herron wrote:
>
> >> Mensanator wrote:
>
> >>> The only way to get a 0 from a reverse range() is to have a bound of
> >>> -1.
>
> >> Not quite. An empty second bound goes all the way to the zero index:
>
> > No
Mensanator wrote:
On Mar 5, 3:42 pm, Gary Herron wrote:
Mensanator wrote:
The only way to get a 0 from a reverse range() is to have a bound of
-1.
Not quite. An empty second bound goes all the way to the zero index:
Not the same thing. You're using the bounds of the sl
On Mar 5, 3:42 pm, Gary Herron wrote:
> Mensanator wrote:
>
> > The only way to get a 0 from a reverse range() is to have a bound of
> > -1.
>
> Not quite. An empty second bound goes all the way to the zero index:
Not the same thing. You're using the bounds of the slice index.
I was refering to
On 2010-03-05 13:10 PM, Robert Kern wrote:
On 2010-03-05 12:28 PM, Steven D'Aprano wrote:
On Fri, 05 Mar 2010 18:12:05 +, Arnaud Delobelle wrote:
l = range(10)
l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
l[7::-1]
[7, 6, 5, 4, 3, 2, 1, 0]
[l[i] for i in range(7, -1, -1)]
[7, 6, 5, 4, 3, 2, 1, 0]
On 3/5/2010 2:10 PM, Robert Kern wrote:
Rather, they have 0 and len(seq), respectively, when the step is
positive, and len(seq)-1 and -1 when the step is negative.
I don't believe the actual behaviour is documented anywhere.
True, I don't think it is.
There are at least two open issues.
Mensanator wrote:
On Mar 5, 12:28 pm, Steven D'Aprano wrote:
On Fri, 05 Mar 2010 18:12:05 +, Arnaud Delobelle wrote:
l = range(10)
l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
l[7::-1]
[7, 6, 5, 4, 3, 2, 1, 0]
[l[i] for i in range(7, -1, -1)]
On Mar 5, 12:28 pm, Steven D'Aprano wrote:
> On Fri, 05 Mar 2010 18:12:05 +, Arnaud Delobelle wrote:
> l = range(10)
> l
> > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
> l[7::-1]
> > [7, 6, 5, 4, 3, 2, 1, 0]
> [l[i] for i in range(7, -1, -1)]
> > [7, 6, 5, 4, 3, 2, 1, 0]
>
> Where does
On 2010-03-05 12:28 PM, Steven D'Aprano wrote:
On Fri, 05 Mar 2010 18:12:05 +, Arnaud Delobelle wrote:
l = range(10)
l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
l[7::-1]
[7, 6, 5, 4, 3, 2, 1, 0]
[l[i] for i in range(7, -1, -1)]
[7, 6, 5, 4, 3, 2, 1, 0]
Where does the first -1 come from? Slices
On Mar 5, 12:01 pm, Joan Miller wrote:
> What does a slice as [N::-1] ?
Starts at position N and returns all items to the start of the
list in reverse order.
>
> It looks that in the first it reverses the slice and then it shows
> only N items, right?
Wrong. It shows N+1 items. Remember, counti
On Fri, Mar 5, 2010 at 11:42 PM, Arnaud Delobelle wrote:
> Joan Miller writes:
>
> > What does a slice as [N::-1] ?
> >
> > It looks that in the first it reverses the slice and then it shows
> > only N items, right?
> >
> > Could you add an example to get the same result without use `::` to
> > s
On Fri, 05 Mar 2010 18:12:05 +, Arnaud Delobelle wrote:
l = range(10)
l
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
l[7::-1]
> [7, 6, 5, 4, 3, 2, 1, 0]
[l[i] for i in range(7, -1, -1)]
> [7, 6, 5, 4, 3, 2, 1, 0]
Where does the first -1 come from? Slices are supposed to have default
On Fri, 05 Mar 2010 10:01:40 -0800, Joan Miller wrote:
> What does a slice as [N::-1] ?
Why don't you try it?
>>> s = "abcdefgh"
>>> s[4::-1]
'edcba'
The rules for extended slicing are not explained very well in the docs,
and can be confusing. In my experience, apart from [::-1] it is best to
Joan Miller writes:
> What does a slice as [N::-1] ?
>
> It looks that in the first it reverses the slice and then it shows
> only N items, right?
>
> Could you add an example to get the same result without use `::` to
> see it more clear?
>
> Thanks in advance
>>> l = range(10)
>>> l
[0, 1, 2,
What does a slice as [N::-1] ?
It looks that in the first it reverses the slice and then it shows
only N items, right?
Could you add an example to get the same result without use `::` to
see it more clear?
Thanks in advance
--
http://mail.python.org/mailman/listinfo/python-list
15 matches
Mail list logo