[Edu-sig] Re: In defense of 0, was Re: None potato, one potato, two potato, more..

Fred Yankowski fred at ontosys.com
Mon Jan 5 13:16:36 EST 2004


Another way to think of [i:j] is as a HALF-OPEN INTERVAL:  all values
from i to j, not including j.

I first encountered this notion in math long ago when considering
ranges of real numbers.  IIRC the notation was such that the
dilimiters "[" and "]" indicated a closed end and "(" and ")" an open
end.  Then, for example, the (non-python) notation "[a,b)" meant "all
real numbers a such that a <= x < b.

Such half-open intervals have the nice property that (continuing with
the non-python syntax) "[a,b)" and "[b, c)" partition the interval
"[a,c)" -- they cover the interval with no overlap, since point b
appears only in the second component interval.

Similarly in Python, x[a:b] + x[b:c] is the same as x[a:c].  This
equivalence is helpful in many applications.

-- 
Fred Yankowski      fred at ontosys.com           tel: +1.630.879.1312
OntoSys, Inc	    PGP keyID: 7B449345        fax: +1.630.879.1370
www.ontosys.com     38W242 Deerpath Rd, Batavia, IL 60510-9461, USA



More information about the Edu-sig mailing list