On 24 April 2018 at 14:46, Nick Coghlan <ncogh...@gmail.com> wrote: > On 24 April 2018 at 23:38, Yury Selivanov <yselivanov...@gmail.com> wrote: >> I propose to use the following syntax for assignment expressions: >> >> ( NAME = expr ) >> >> I know that it was proposed before and this idea was rejected, because >> accidentally using '=' in place of '==' is a pain point in >> C/C++/JavaScript. >> >> That said, I believe we can still use this syntax as long as we impose >> the following three restrictions on it: >> >> 1. Only NAME token is allowed as a single target. >> >> 2. Parenthesis are required. >> >> 3. Most importantly: it is *not* allowed to mask names in the current >> local scope. > > While I agree this would be unambiguous to a computer, I think for > most humans it would be experienced as a confusing set of arcane and > arbitrary rules about what "=" means in Python.
Also, there's the ambiguity and potential for misreading in the opposite direction (accidentally *reading* = as == even though it isn't): if (diff = x - x_base) and (g = gcd(diff, n)) > 1: return g My immediate reading of this is as an equality comparison between diff and x - x_base (which would send me futilely looking for a definition of diff) and an equality comparison of g and gcd(diff, n)... wait, why am I doing (equality comparison) > 1? Oh, hang on... At this point, any hope of me quickly understanding what this code does is lost. Paul _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com