Assignment Versus Equality

Lawrence D’Oliveiro lawrencedo99 at gmail.com
Sun Jun 26 03:36:47 EDT 2016


One of Python’s few mistakes was that it copied the C convention of using “=” for assignment and “==” for equality comparison.

It should have copied the old convention from Algol-like languages (including Pascal), where “:=” was assignment, so “=” could keep a meaning closer to its mathematical usage.

For consider, the C usage isn’t even consistent. What is the “not equal” operator? Is it the “not” operator concatenated with the “equal” operator? No it’s not! It is “!” followed by “=” (assignment), of all things! This fits in more with the following pattern:

    A += B <=> A = A + B
    A *= B <=> A = A * B

in other words

    A != B

should be equivalent to

    A = A ! B



More information about the Python-list mailing list