Assignment Versus Equality

MRAB python at mrabarnett.plus.com
Sun Jun 26 11:41:48 EDT 2016


On 2016-06-26 11:48, 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.
>
> However, why couldn't Python have used "=" both for assignment, and for
> equality? Since I understand assignment ops can't appear in expressions.
>
[snip]

Python supports chained assignments. For example, "a = b = 0" assigns 0 
to both a and b.

I'm not sure how common it is, though. I virtually never use it myself.




More information about the Python-list mailing list