4 ms·
They address this briefly in the PEP[0], and it's largely because they want to be very clear about when it's happening. The distance between if x = y: and
by andolanra 7y ago
They address this briefly in the PEP[0], and it's largely because they want to be very clear about when it's happening. The distance between
if x = y:
and
if x == y:
is very small, and easy to ignore, so insisting on
if x := y:
makes it very clear that what's happening won't be mistaken for comparison at a quick glance.
[0]: https://www.python.org/dev/peps/pep-0572/#why-not-just-turn-existing-assignment-into-an-expression https://www.python.org/dev/peps/pep-0572/#why-not-just-turn-...