Range Operation pre-PEP

Steve Holden sholden at holdenweb.com
Wed May 9 22:00:09 EDT 2001


"Delaney, Timothy" <tdelaney at avaya.com> wrote ...
[ ... ]
> Well, there would be a simple way to make ranges that conformed to both.
Use
> the mathematical notation for describing inclusive and exclusive bounds
> (although it would be using '..' instead of ',').
>
> If I remember correctly ...
>
> [0..10] - range is 0 to 10
> [0..10) - range is 0 to 9
> (0..10] - range is 1 to 10
> (0..10) - range is 1 to 9
>
Correct me if I'm wrong, but don't the concepts of open and closed intervals
belong to analysis and not discrete mathematics -- in other words, they
apply to infinite sets but not finite ones. An open interval (x,y) is the
set of all numbers strictly greater than x and strictly less than y.
Dedekind will be turning in his grave...

This proposed notation (and you aren't the first to propose it) would be
bizarrely misunderstood by newcomers. I certainly don't want to have to
explain that the same object can be described in four different ways, and
suggest when [1..9] is more appropriate than (0..10) is more appropriate
than [1..10) is more appropriate than (0..9].

So, why have four representations for the same thing?

there-should-be-one-obvious-way-to-do-it-ly y'rs  - steve




More information about the Python-list mailing list