Disclaimer: I am not asking if the upper-bound stop
argument of slice()
and range()
is exclusive or how to use these functions.
Calls to the range
and slice
functions, as well as the slice notation [start:stop]
all refer to sets of integers.
range([start], stop[, step])
slice([start], stop[, step])
In all these, the stop
integer is excluded.
I am wondering why the language is designed this way.
Is it to make stop
equal to the number of elements in the represented integer set when start
equals 0 or is omitted?
Is it to have:
for i in range(start, stop):
look like the following C code?
for (i = start ; i < stop; i++) {
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…