Re: basic if stuff- testing ranges

2007-11-26 Thread John Machin
On Nov 27, 3:01 am, Erik Jones <[EMAIL PROTECTED]> 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

Re: basic if stuff- testing ranges

2007-11-26 Thread Erik Jones
On Nov 26, 2007, at 2:29 AM, Peter Otten wrote: > Donn Ingle wrote: > >>> x in range(1,20) ? >> Sure, that's okay, but it has clarity issues, and is calling a func. > > and it requires that x is integral (1.0 is in the range, 1.001 is > not), > and becomes dog slow when the range gets larger. No

Re: basic if stuff- testing ranges

2007-11-26 Thread Erik Jones
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. > >> L

Re: basic if stuff- testing ranges

2007-11-26 Thread Donn Ingle
> The output of the following program might help: Hey, nifty! Thanks Paddy. \d -- http://mail.python.org/mailman/listinfo/python-list

Re: basic if stuff- testing ranges

2007-11-26 Thread Peter Otten
Donn Ingle wrote: >> x in range(1,20) ? > Sure, that's okay, but it has clarity issues, and is calling a func. and it requires that x is integral (1.0 is in the range, 1.001 is not), and becomes dog slow when the range gets larger. Not a good idea. Peter -- http://mail.python.org/mailman/listin

Re: basic if stuff- testing ranges

2007-11-25 Thread Paddy
On Nov 25, 6:49 pm, Donn Ingle <[EMAIL PROTECTED]> wrote: > Sheesh, I've been going spare trying to find how to do this short-hand: > if 0 > x < 20: print "within" > > 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? >

Re: basic if stuff- testing ranges

2007-11-25 Thread Donn Ingle
>> 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,

Re: basic if stuff- testing ranges

2007-11-25 Thread Donn Ingle
> > if 0 > x: print "within" > Ah, I didn't know you could one could use the sarcasm.xml module and then use tags to influence Python commands. Most interesting... import sarcasm.xml I.fartIn( Your.Direction( general ) ) :D \d -- http://mail.python.org/mailman/listinfo/python-list

Re: basic if stuff- testing ranges

2007-11-25 Thread Donn Ingle
Mel wrote: > if 0 < x < 20: > ? I take it I was tripping then. That's okay, it seemed a little too weird anyway :) \d -- http://mail.python.org/mailman/listinfo/python-list

Re: basic if stuff- testing ranges

2007-11-25 Thread Donn Ingle
> you mean : 0 < x < 20 ? Yes. I had gotten the impression that there was some Python form of: if NUMBER test VAR test NUMBER: Part of the question was to discover if I was smoking my socks :) > x in range(1,20) ? Sure, that's okay, but it has clarity issues, and is calling a func. >> but then a

Re: basic if stuff- testing ranges

2007-11-25 Thread J. Clifford Dyer
On Sun, 2007-11-25 at 20:49 +0200, Donn Ingle wrote: > Sheesh, I've been going spare trying to find how to do this short-hand: > if 0 > x < 20: print "within" > if 0 > x: print "within" -- http://mail.python.org/mailman/listinfo/python-list

Re: basic if stuff- testing ranges

2007-11-25 Thread John Machin
On Nov 26, 5:49 am, Donn Ingle <[EMAIL PROTECTED]> wrote: > Sheesh, I've been going spare trying to find how to do this short-hand: > if 0 > x < 20: print "within" That means "if x LESS THAN 0 and x < 20". > > So that x must be > 0 and < 20. So try if 0 < x < 20: > > I usually do: > if x >

Re: basic if stuff- testing ranges

2007-11-25 Thread Aurélien Campéas
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

Re: basic if stuff- testing ranges

2007-11-25 Thread Mel
Donn Ingle wrote: > Sheesh, I've been going spare trying to find how to do this short-hand: > if 0 > x < 20: print "within" > > 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? if 0 < x < 20: ? Mel. -

basic if stuff- testing ranges

2007-11-25 Thread Donn Ingle
Sheesh, I've been going spare trying to find how to do this short-hand: if 0 > x < 20: print "within" 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? I read something like it recently on the list but can't find it, that's whe