Slicing history?

Steve Howell showell30 at yahoo.com
Sun Nov 15 15:40:44 EST 2009


On Nov 15, 12:11 pm, Mark Dickinson <dicki... at gmail.com> wrote:
> On Nov 15, 6:50 pm, a... at pythoncraft.com (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.
>
> Sounds like an excuse to post this Dijkstra link:
>
> http://www.cs.utexas.edu/~EWD/ewd08xx/EWD831.PDF
>

That is really good stuff!  Like Aahz I have Python's slicing
mechanism (and zero-based indexing) burnt into my brain, but I never
had a good way to explain why it makes sense, other than just an
intuitive notion that it works for me.  It is interesting how the link
actually seems to explain zero-based indexing as a consequence of the
slicing approach, not a cause.  I always understood zero-based
indexing as a relic of memory management, which was fine, but I guess
the reasons go deeper than that.







More information about the Python-list mailing list