basic if stuff- testing ranges

John Machin sjmachin at lexicon.net
Mon Nov 26 16:18:46 EST 2007


On Nov 27, 3:01 am, Erik Jones <e... at myemma.com> wrote:
> On Nov 25, 2007, at 9:49 PM, Donn Ingle wrote:
>
>
>
> >>> if 0 > x < 20: print "within"
> >> That means "if x LESS THAN 0 and x < 20".
> > Oh, bugger. It's tricky.
> >> So try
> >>     if 0 < x < 20:
> > Thanks. I was flipping signs in my tests, but I guess I flipped
> > both and got
> > myself all confused.
>
> >> Likely manuals: Tutorial & Reference
> >> Tutorial: check contents, "if statement" looks possible, but no luck
> > Yes, I got that far.
> >> Reference: check contents, "comparisons" looks possible, and
> > Thanks again. I find the reference is laid-out in a way that I
> > don't find
> > intuitive and every time I look for something I fail. I even grep
> > through
> > the folder to get a clue, which shows how poor the index is (to me)!
>
> Then use one of the quick references here:http://rgruet.free.fr/.
>

Generally excellent references, but "X < Y < Z < W has expected
meaning, unlike C" is not much help to people who have not been
exposed to similar notation (e.g. 0 <= angle < 2 * pi) in other
disciplines and/or know C merely as a member of the same set as X, Y,
Z and W.



More information about the Python-list mailing list