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

Tell me the truth

2007-03-08 Thread francois . petitjean
In the python-ideas mailing list http://mail.python.org/pipermail/python-ideas/2007-March/thread.html there was a discussion about the fact that python has opeartors 'and', 'or' and 'not' (keywords of the language) but 'bool' is a type. Naturally we have (not not x) == bool(x) # always True If