John Dann <[EMAIL PROTECTED]> writes: > I suppose there must be some logic in including the start position > but excluding the end position, though it does escape me for now. I > can understand making a range inclusive or exclusive but not a > mixture of the two. Suppose it's just something you have to get used > to with Python and, no doubt, much commented on in the past.
Half-open ranges are not specific to Python: for example, they're used in Java (String.substring), Lisp (start and stop arguments to sequence functions), and C++ (STL algorithms accept begin and end iterators that generalize from pointers to the beginning and one-past-the-end of an array). Ranges so expressed have several nice properties. The size of the range is expressed simply as b-a, you don't need to remember to add 1. Empty range is easily expressed as [a, a>, rather than the much less intuitive [a, a-1] for all-inclusive ranges. Consecutive ranges are easily concatenated without missing or duplicating an element, so [a, b> + [b, c> is exactly equivalent to [a, c>. -- http://mail.python.org/mailman/listinfo/python-list