Arithmetic sequences in Python
Alex Martelli
aleax at mail.comcast.net
Mon Jan 16 11:35:05 EST 2006
Steven D'Aprano <steve at REMOVETHIScyber.com.au> wrote:
> On Mon, 16 Jan 2006 12:51:58 +0100, Xavier Morel wrote:
>
> > For those who'd need the (0..n-1) behavior, Ruby features something that
> > I find quite elegant (if not perfectly obvious at first), (first..last)
> > provides a range from first to last with both boundaries included, but
> > (first...last) (notice the 3 periods)
>
> No, no I didn't.
>
> Sheesh, that just *screams* "Off By One Errors!!!". Python deliberately
> uses a simple, consistent system of indexing from the start to one past
> the end specifically to help prevent signpost errors, and now some folks
> want to undermine that.
>
> *shakes head in amazement*
Agreed. *IF* we truly needed an occasional "up to X *INCLUDED*"
sequence, it should be in a syntax that can't FAIL to be noticed, such
as range(X, endincluded=True).
Alex
More information about the Python-list
mailing list