Ifs and assignments

Chris Angelico rosuav at gmail.com
Thu Jan 2 22:55:24 EST 2014


On Fri, Jan 3, 2014 at 2:33 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Personally, I find it hard to care about assignment as an expression. I find
> the obvious C-inspired syntax terrible, as it is too easy to mistakenly use
> == instead of = or visa versa:

Python has similar problems, though. It's inherent to the nature of
symbolic languages.

a = (1, 2, 3)
b = {1, 2, 3}

In many fonts, it's hard to tell one from the other without peering.
Do people decry set literal notation in favour of explicitly writing
the word "set"? No; and I think most of us agree that it's better to
have the symbols. At least with == vs = there's a length difference. I
don't think it's C's fault or problem that equality and assignment
look similar and can be used in the same places, any more than it's a
problem to have assignment and subtraction differ by only one stroke:

a - (1, 2, 3)

Is that confusingly similar to assignment?

ChrisA



More information about the Python-list mailing list