Tommy Grav <[EMAIL PROTECTED]> wrote: > On Apr 19, 2007, at 11:00 PM, Alex Martelli wrote: > > > Alan Isaac <[EMAIL PROTECTED]> wrote: > > > >> currently documented behavior: > >> "objects of different types always compare unequal". > > > > Where is that documented? URL please? > > > >>>> 1.0 == 1 > > True > >>>> type(1.0), type(1) > > (<type 'float'>, <type 'int'>) > > > > 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.
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'. >>> u'ciao' == 'ciao' True >>> type(u'ciao'), type('ciao') (<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 -- http://mail.python.org/mailman/listinfo/python-list