[Python-Dev] A proposal has surfaced on comp.lang.python to r
edefine "is"
Gareth McCaughan
GMcCaughan at synaptics-uk.com
Thu Mar 18 08:01:06 EST 2004
Peter Norvig wrote:
> Let me point out that in Common Lisp, there are five equality
> predicates:
>
> eq like Python's 'is', only true for identical objects
> eql also true for numbers with same value
Numbers and characters; characters as well as numbers
may behave counterintuitively w.r.t EQ.
> equal like Python's '=='
> equalp also true for strings with different case
> = only works on numbers, true if they are eql after
> conversion to the same type
Ha. Don't forget
char= only works on characters, equivalent to EQL then
char-equal only works on characters, ignores case
string= only works on strings, equivalent to EQUAL then
string-equal only works on strings, ignores case
> I would say that Python is served well by the two equality predicates
> it has, that it is impossible to please everyone, and that users
> should get used to writing the predicate they want if it is not one of
> the builtins.
Agreed. Although the fact that EQL is much more useful in practice
than EQ suggests that there's something to be said for making Python's
"is" more EQL-like. (Not enough, in my opinion, to make it worth doing.)
--
g
More information about the Python-Dev
mailing list