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
"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
> >
[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
[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