I was going to submit a bug, but then I realised that I might just be
mis-interpreting what the documentation says (or maybe it'd not even
supposed to be so precise a specification). Any comments or
confirmation on this?

--
Raoul Gough
"Let there be one measure for wine throughout our kingdom, and one
measure for ale, and one measure for corn" - Magna Carta

Advertisements

Raoul Gough <> writes:
> As of Python 2.3, Section 2.2.6 (Sequence Types) describes slices
> which have a specified step (to omit some indexes in beteween), using
> the notation s[i:j:k]. The note about how this works says:
>
> "The slice of s from i to j with step k is defined as the sequence
> of items with index x = i + n*k such that 0 <= n < abs(i-j). [...]"
>
> Seems to me that "0 <= n < abs(i-j)" is wrong, since the range of n
> gets multiplied by k.

How about "0 <= n < abs(k*(i-j))"? But you're right, what's there is
a bit wrong. It's surprisingly hard to get this written down well.
The idea's not that hard, but a terse explanation is surprisingly
hard (when you start omitting values it gets even more fun!).

Please submit a patch (assign it to me if you like -- the above
passage is my fault).

Cheers,
mwh

--
This same programmer had worked for the military, and therefore had
access to weapons-grade cursing technology.
-- Matt Roberds, asr

Advertisements

On Thu, 21 Aug 2003 17:12:28 GMT, rumours say that Michael Hudson
<> might have written:
>> "The slice of s from i to j with step k is defined as the sequence
>> of items with index x = i + n*k such that 0 <= n < abs(i-j). [...]"

Michael Hudson <> writes:
> Raoul Gough <> writes:
>> Seems to me that "0 <= n < abs(i-j)" is wrong, since the range of n
>> gets multiplied by k.
>
> How about "0 <= n < abs(k*(i-j))"? But you're right, what's there is
> a bit wrong. It's surprisingly hard to get this written down well.
> The idea's not that hard, but a terse explanation is surprisingly
> hard (when you start omitting values it gets even more fun!).
>
> Please submit a patch (assign it to me if you like -- the above
> passage is my fault).

I've submitted a bug to the sourceforge tracker for Python, but
couldn't see how to assign it to anyone. Bug number is 792656, hope
this is what you meant.

--
Raoul Gough
"Let there be one measure for wine throughout our kingdom, and one
measure for ale, and one measure for corn" - Magna Carta

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!