Alex Martelli wrote: > Colin J. Williams <[EMAIL PROTECTED]> wrote: > ... > >>>>I am also open to such arguments but it will be tough to convince me >>>>that "x to y" should mean something different from what it means in >>>>Pascal, BASIC, and English. >>> > ... > >>1. Why not treat '2 to 5' or '(2 to 5)' as a semi-open interval? > > > Reread the part I quoted above: at least some of the proponents of this > syntax appear to be totally ignorant of 30 years of literature and > practice of programming, "it will be tough to convince" them that closed > intervals are a terrible mistake and semi-open ones the only way to go.
I intellectually understand that semi-open intervals are the only way to go. But reading the words, the part of my brain that speaks English cries out for a closed interval. Bad brain. Given the overwhelming benefit of semi-closed intervals, I wish to amend my proposal to follow Alex's suggestions, namely: for i in (1 to 10 by 3): print i should print 1 4 7. That would make (a to b by c) equivalent to range(a,b,c) except that it returns an iterator rather than a list. Hmmm... putting it that way, the new syntax actually costs 1 keystroke, or saves 1 if you put spaces after the commas in the range expression. Does it add enough clarity and ease of understanding to justify two new keywords? > Introducing a new syntax, with semantics that "don't convince" some of > its prominent proponents, would be self-destructive (I shudder just to > think of the amount of time and energy we'd all be spending dealing with > whines about it); Python is clearly much better off if such people run > away to Ruby, with its (expletive deleted) a..b AND a...b syntaxes just > to ensure maximum confusion;-). Ruby uses both .. and ...? Now I'm frightened. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list