Re: comparison with None
Tommy Grav <tgrav@mac.comw rote:
Operator == (TWO equal signs, not just one: that would be an assignment
instead) can be applied to arbitrary objects, not just numbers, just
like operator 'is'.
True
(<type 'unicode'>, <type 'str'>)
See, it's not a question of numbers versus other things: the
distinction, rather, is between comparison of the values of objects
(which can perfectly well be equal even for objects of different types)
versus checking object identity (and since an object only has one type
at a time, it can't be "the same object" as one with a different type).
Why do you think the Python docs don't draw the difference between '=='
(equality) and 'is' (identity)?
I'm still interested to know where that erroneous quote from Alan Isaac
comes from, because if it's in Python's docs, it can be fixed.
Alex
Tommy Grav <tgrav@mac.comw rote:
On Apr 19, 2007, at 11:00 PM, Alex Martelli wrote:
>
>
Isn't this an example of numerical comparison (= or !=) versus
object comparison (is or is not). I think the documentation needs
to state that there is a difference between the two types.
>
Alan Isaac <aisaac@america n.eduwrote:
Where is that documented? URL please?
True
(<type 'float'>, <type 'int'>)
currently documented behavior:
"objects of different types always compare unequal".
"objects of different types always compare unequal".
>>1.0 == 1
>>type(1.0), type(1)
Isn't this an example of numerical comparison (= or !=) versus
object comparison (is or is not). I think the documentation needs
to state that there is a difference between the two types.
instead) can be applied to arbitrary objects, not just numbers, just
like operator 'is'.
>>u'ciao' == 'ciao'
>>type(u'ciao') , type('ciao')
See, it's not a question of numbers versus other things: the
distinction, rather, is between comparison of the values of objects
(which can perfectly well be equal even for objects of different types)
versus checking object identity (and since an object only has one type
at a time, it can't be "the same object" as one with a different type).
Why do you think the Python docs don't draw the difference between '=='
(equality) and 'is' (identity)?
I'm still interested to know where that erroneous quote from Alan Isaac
comes from, because if it's in Python's docs, it can be fixed.
Alex
Comment