Page 1 of 1

a < b < c

PostPosted: Sat Jun 06, 2009 10:56 pm
by Charles
I think it might be time to implement Python's convenient grammar for checking numeric ranges. I find myself writing this too many times:
x >= 0 and x <= 1

# which could just be:
0 <= x <= 1

# so the general form is:
<expr-a> <comparison> <expr-b> <comparsion> <expr-c>

Sound good?

Re: a < b < c

PostPosted: Sun Jun 07, 2009 4:12 am
by natter
this looks very cryptic and breaks a bit with cobras readability imo


but i would also like to see a general feature to shorten up lines with repeating elements:

a not inherits b and a not inherits c and a not inherits d
a > 0 and a < 7 and a != 3

Re: a < b < c

PostPosted: Mon Jun 15, 2009 12:56 pm
by todd.a
I actually think it is more readable because by having
0 <= x <= 1

you can easily see that x is bounded by 0 and 1

Re: a < b < c

PostPosted: Tue Jun 16, 2009 2:12 am
by Charles
I added a ticket for this.
ticket:161