Annoying behaviour of the != operator

Matt Warden mwarden at
Wed Jun 8 21:04:44 CEST 2005


On 8 Jun 2005 11:44:43 -0700, Jordan Rastrick
<jrastrick at> wrote:
> But I explicitly provided a method to test equality. And look at the
> plain english meaning of the term "Not equals" I think its pretty
> reasonable

Indeed. Furthermore, it seems quite silly that these would be different:

a != b
not (a == b)

To be fair, though, other languages have peculiarities with equation.
Consider this Java code:

String s1 = "a";
String s2 = "a";
String s3 = new String("a");
String s4 = new String("a");

s1 == s2; // true
s1.equals(s2); // true

s1 == s3; // false
s1.equals(s3); // true

s3 == s4; // false
s3.equals(s4); // true

Doesn't make it any less silly, though.

Matt Warden
Miami University
Oxford, OH, USA

This email proudly and graciously contributes to entropy.

More information about the Python-list mailing list