basic if stuff- testing ranges

Aurélien Campéas spamless.aurelien.campeas at free.fr
Sun Nov 25 14:00:09 EST 2007


Donn Ingle a écrit :
> Sheesh, I've been going spare trying to find how to do this short-hand:
> if 0 > x < 20: print "within"

you mean : 0 < x < 20 ?

or

x in xrange(1,20) ?

> 
> So that x must be > 0 and < 20.
> 
> I usually do:
> if x > 0 and x < 20: print "within"
> 
> What's the rule? Does it even exist?

is that hard to check it at the repl ?

> I read something like it recently on the list but can't find it, that's
> where I got the urge to try it from. I can't find anything in the docs, but
> then again (imho) the Python docs are like a tangled jungle...

<something smug, refrained/>

> 
> 
> \d
> 



More information about the Python-list mailing list