inclusive-lower-bound, exclusive-upper-bound (was Re: Range Operation pre-PEP)

Gareth McCaughan Gareth.McCaughan at pobox.com
Mon May 14 16:07:40 EDT 2001


Alex Martelli wrote:

[someone else:]
> > one reason is so that for 0 <= n < len(a),
> >
> >     a[:n]+a[n:] == a
> >
> > That property makes processing sections of lists much simpler.
[Alex:]
> Yes, but, is the constraint on n necessary?  It seems to me both
> by reasoning and by experiment that this nice and useful property
> holds for ALL n, e.g.:
[SNIP]

Indeed. On the other hand, a related identity you asserted
in another article

    range(x,y) + range(y,z) == range(x,z)

fails, e.g., if x,y,z == 1,10,4. It's entertaining
to think about what we'd have to do to ranges to
enable the identity to be true for *all* x,y,z. :-)

-- 
Gareth McCaughan  Gareth.McCaughan at pobox.com
.sig under construc



More information about the Python-list mailing list