"!=" is bad form. Re: sorry....never mind

James Logajan JamesL at Lugoj.Com
Thu Mar 8 01:10:27 EST 2001


Greg Ewing wrote:
> 
> Victor Louie wrote:
> >
> > <> is obsolescent.
> 
> Really? I hope it's not taken away, because that will
> break ALL of my code! I hate != (looks too much like
> C), so I always use <>. Nobody ever told me I was doing
> anything wrong!

Actually, for Python, "!=" IS totally bogus and should be considered the
unusual variant. Unless the logical negation operation has been changed from
"not" to "!" (shucks, version 1.5.2 still does all I need) then "!=" is not
suggestive of anything. In "C" the "!=" was suggestive of:

!(expression1 == expression2)

But Python doesn't use "!" for "not". The operations "<", ">", "<=", ">=",
"==", "<>" form a nice consistent and predictable set. The only objection
that has been made against "<>" is that it implies ordering when the
entities being compared may not have any ordering. Even granting this
dubious objection does not excuse the introduction of a form that is no
where else implied, hinted at, or suggested in any way by any other part of
the language. Guido made a mistake here and shows that even the brightest
can stumble once in a while.

Shucks, if one is going to borrow "!=" from "C", why stop there? Why not
borrow the keywords and concepts such as "register", "auto", "extern",
pointers, malloc, free, etc.



More information about the Python-list mailing list