[Python-ideas] [Python-Dev] Inclusive Range
denis.spir at gmail.com
Tue Oct 5 21:23:27 CEST 2010
On Tue, 05 Oct 2010 13:45:56 +0200
Boris Borcic <bborcic at gmail.com> wrote:
> Nick Coghlan wrote:
> > [...] Being able to say things like
> > "10:00"<= x< '12:00", 10.0<= x< 12.0, "a"<= x< "n" are much
> > clearer than trying to specify their closed range equivalents.
> makes one wonder about syntax like :
> for 10 <= x < 20 :
> Mh, I suppose with rich comparisons special methods, it's possible to turn
> chained comparisons into range factories without introducing new syntax.
> Something more like
> for x in (10 <= step(1) < 20) :
About notation, even if loved right-hand-half-open intervals, I would wonder about [a,b] noting it. I guess 99.9% of programmers and novices (even purely amateur) have learnt about intervals at school in math courses. Both notations I know of use [a,b] for closed intervals, while half-open ones are noted either [a,b[ or [a,b). Thus, for me, the present C/python/etc notation is at best misleading.
So, what about a hypothetical language using directly math *unambiguous* notation, thus also letting programmers chose their preferred semantics (without fooling others)? End of war?
-- -- -- -- -- -- --
vit esse estrany ☣
More information about the Python-ideas