Re: Tell me the truth

2007-03-08 Thread francois . petitjean
Duncan Booth wrote : > francois.petitjean at bureauveritas.com wrote: >> After much head scrating and experimenting with dis.dis() I have found >> that chaining comparisons (with is or ==) a == b == c in Python is >> never a good idea. It is interpreted as >> ( a == b ) and ( b == c) >> Such a m

Re: Tell me the truth

2007-03-08 Thread Erik Johnson
"Duncan Booth" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [EMAIL PROTECTED] wrote: > > > After much head scrating and experimenting with dis.dis() I have found > > that chaining comparisons (with is or ==) a == b == c in Python is > > never a good idea. It is interpreted as > >

Re: Tell me the truth

2007-03-08 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > After much head scrating and experimenting with dis.dis() I have found > that chaining comparisons (with is or ==) a == b == c in Python is > never a good idea. It is interpreted as > ( a == b ) and ( b == c) > Such a magic is fine when we write: > if 0.0 <= x < 1.0

Re: Tell me the truth

2007-03-08 Thread Mikael Olofsson
[EMAIL PROTECTED] wrote: > If I take into account the fact that 'True' and 'False' are singletons > (guaranteed ?) : > (not not x) is bool(x) # should be always True. > [snip code and results of code] > Consider the following: >>> def ok1(x): return (not not x) is bool(x) >>> def ok2