Slicing history?

Nobody nobody at
Sun Nov 15 20:19:01 CET 2009

On Sun, 15 Nov 2009 10:50:43 -0800, Aahz wrote:

> Anyone remember or know why Python slices function like half-open
> intervals?  I find it incredibly convenient myself, but an acquaintance
> familiar with other programming languages thinks it's bizarre and I'm
> wondering how it happened.

How else would they function? Closed intervals?

Using a closed interval (for just about anything) indicates that the
designer has very limited programming experience. Anyone with a modicum of
programming experience knows that half-open intervals are the norm, and
that using closed intervals will confuse anyone else with a modicum of
programming experience.

That's aside from the objective merits, i.e. the fact that they can be
used to partition an interval into subintervals without having to
adjust the upper bound (which requires knowing how much to adjust the
upper bound by, if that's even possible (for reals, it isn't)).

More information about the Python-list mailing list