[Python-Dev] assignment expressions: an alternative proposal (original) (raw)
Paul Moore p.f.moore at gmail.com
Tue Apr 24 11:07:10 EDT 2018
- Previous message (by thread): [Python-Dev] assignment expressions: an alternative proposal
- Next message (by thread): [Python-Dev] assignment expressions: an alternative proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 24 April 2018 at 15:58, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
On Tue, Apr 24, 2018 at 10:49 AM, Paul Moore <p.f.moore at gmail.com> wrote: [..]
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 - xbase) and (g = gcd(diff, n)) > 1: return g Since 'diff' and 'g' must be new names according to rule (3), those who read the code will notice that both were not previously bound. Therefore both are new variables so it can't be a comparison.
That was essentially my point, though - I can no longer read that line of code in isolation from the surrounding context. Consider something like a github PR review screen, where surrounding unchanged code is frequently hidden.
Anyway, we can agree to differ on this - I don't like this idea and I'd personally find it hard to read, but as you've already pointed out, this is all extremely subjective. Paul
- Previous message (by thread): [Python-Dev] assignment expressions: an alternative proposal
- Next message (by thread): [Python-Dev] assignment expressions: an alternative proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]