On Nov 15, 12:11 pm, Mark Dickinson <dicki...@gmail.com> wrote:
> On Nov 15, 6:50 pm, a...@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.




-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to