Questions regarding design decisions in listobject.c
Alex Martelli
alex at magenta.com
Mon Jun 12 08:25:46 EDT 2000
More information about the Python-list mailing list
Mon Jun 12 08:25:46 EDT 2000
- Previous message (by thread): Questions regarding design decisions in listobject.c
- Next message (by thread): Questions regarding design decisions in listobject.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Martijn Faassen <m.faassen at vet.uu.nl> wrote in message news:8hlr8r$77a$1 at newshost.accu.uu.nl... > Courageous <jkraska1 at san.rr.com> wrote: > [snip] > > Well, yeah, but [0:3] as "element zero through three, inclusive" > > is about as intuitive as you can get. While I understand completely > > how the current implementation works (reading the source code and > > all, dontcha know), I still fail to see *why* this was chosen. > > a[0:i] + a[i:] == a > > a[0:len(a)] == a > > Inserting a list at index i: > > a[:i] + b + a[i:] > > In practice, no need to think about a *lot* of off-by-one errors. Koenig's excellent book on C's traps and pitfalls is where I first saw advocacy for the style of "lower bound included, upper bound excluded" and lots of good reasons for it. Today, of course, the style is pervasive in C++'s standard library, and in Python too. It's truly a good idea. Alex
- Previous message (by thread): Questions regarding design decisions in listobject.c
- Next message (by thread): Questions regarding design decisions in listobject.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list