Assignment Versus Equality

Gregory Ewing greg.ewing at
Sun Jun 26 19:22:24 EDT 2016

BartC wrote:
> On 26/06/2016 08:36, Lawrence D’Oliveiro wrote:
>> One of Python’s few mistakes was that it copied the C convention of 
>> using “=” for assignment and “==” for equality comparison.
> One of C's many mistakes. Unfortunately C has been very influential.

I'm not sure it's fair to call it a mistake. C was
designed for expert users, and a tradeoff was likely
made based on the observation that assignment is
used much more often than equality testing.

> However, why couldn't Python have used "=" both for assignment, and for 
> equality?

Because an expression on its own is a valid statement,

    a = b

would be ambiguous as to whether it meant assigning b
to a or evaluating a == b and discarding the result.


More information about the Python-list mailing list