[Python-Dev] assignment expressions: an alternative proposal
Yury Selivanov
yselivanov.ml at gmail.com
Tue Apr 24 11:19:27 EDT 2018
More information about the Python-Dev mailing list
Tue Apr 24 11:19:27 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 Tue, Apr 24, 2018 at 11:07 AM, Chris Angelico <rosuav at gmail.com> wrote: [..] > x = 1 > if (x = 2): ... > > This, according to your proposal, raises SyntaxError - not because a > comparison was wanted and an assignment was made, but because the name > already had a value. And, even worse, this is NOT an error: Yes, because I'm trying to think about this from a pragmatic side of things. My question to myself: "what syntax could I use that would prevent me from making '=' vs '==' mistake when I code?" To me, the answer is that I usually want to compare local variables. When I compare to variables from outer scopes they *usually* are on the *right* side of '=='. > > x = 1 > def f(): > if (x = 2): > ... > > That's a bizarre distinction. Chris, FWIW I'm trying to avoid using 'bizarre', 'arcane' etc with regards to PEP 572 or any proposal, really. For example, I, personally, find ':=' bizarre, but it's subjective and it's unproductive to say that. Yury
- 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 ]
More information about the Python-Dev mailing list