[Python-bugs-list] [ python-Bugs-792656 ] Misleading [i:j:k] slicing description

SourceForge.net noreply at sourceforge.net
Sat Aug 30 17:42:59 EDT 2003


Bugs item #792656, was opened at 2003-08-21 13:02
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=792656&group_id=5470

Category: Documentation
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Raoul Gough (raoulgough)
Assigned to: Michael Hudson (mwh)
Summary: Misleading [i:j:k] slicing description

Initial Comment:
Section 2.2.6 (Sequence types), note 5 from the table 
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). [...]"

However, n should only range up to (j-i)//k

Note also that (j-i)//k correctly specifies the results for 
negative values of k, and empty sequence returns 
where signof(j-i) != signof (k). Maybe worth mentioning 
that k != 0  (!! :-)

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

>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-08-30 18:42

Message:
Logged In: YES 
user_id=80475

Applied Tzot's patch.
mwh can re-open if anything else needs to be done.

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

Comment By: Christos Georgiou (tzot)
Date: 2003-08-29 04:57

Message:
Logged In: YES 
user_id=539787

See patch 797180 http://www.python.org/sf/797180

the above is changed to:

such that \code{0} \code{<=} \var{n} \code{<} \code{abs
(j-i)//k} (\code{k} cannot be zero).

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

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



More information about the Python-bugs-list mailing list