[Python-ideas] [Python-Dev] Inclusive Range

Chris Rebert clp2 at rebertia.com
Tue Oct 5 22:52:39 CEST 2010

On Tue, Oct 5, 2010 at 1:31 PM, Wolfgang Rohdewald
<wolfgang at rohdewald.de> wrote:
> On Dienstag 05 Oktober 2010, MRAB wrote:
>> > About notation, even if loved right-hand-half-open
>> > intervals, I would wonder about [a,b] noting it. I guess
>> > 99.9% of programmers and novices (even purely amateur) have
>> > learnt about intervals at school in math courses. Both
>> > notations I know of use [a,b] for closed intervals, while
>> > half-open ones are noted either [a,b[ or [a,b). Thus, for
>> > me, the present C/python/etc notation is at best
>> > misleading. So, what about a hypothetical language using
>> > directly math unambiguous notation, thus also letting
>> > programmers chose their preferred semantics (without
>> > fooling others)? End of war?
>> Dijkstra came to his conclusion after seeing the results of
>> students using the programming language Mesa, which does
>> support all 4 forms of interval.
> what was his conclusion?

That right-hand-half-open intervals (i.e. a <= i < b, equivalently [a,
b) ), which are what Python uses, are to be preferred.
(See aforelinked PDF: http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF)


More information about the Python-list mailing list