Re: [Python-Dev] PEP 572: Assignment Expressions

2018年4月17日 17:24:07 -0700

On Tue, Apr 17, 2018 at 3:23 PM, Tim Peters <[email protected]> wrote:
> [Tim]
> >> I'll channel that Guido would be happiest if this rule were followed:
> >>
> >> Given an assignment statement using "=", the meaning is the same if
> >> "=" is replaced with ":=".
>
Thanks for channeling me. :=)
I'd like Guido to chime in again, because I'm pretty sure he won't
> accept what's currently on the table. There are two plausible ways to
> repair that:
>
> 1. Continue down the road of making assignment expressions "exactly
> like" assignment statements in their full generality.
>
> 2. Back off and limit assignment expressions to what appears to be the
> overwhelmingly most common case motivated by looking at real code (as
> opposed to constructing examples to illustrate pitfalls &
> obscurities):
>
> identifier ":=" expression
>
I haven't had the time to follow this thread in detail; fortunately I don't
have to because of Tim's excellent channeling.
I am fine with this, it certainly seems the easiest to implement, with the
fewest corner cases, and the easiest restriction to explain.
(I was thinking there would be a use case for basic tuple unpacking, like
seen a lot in for-loop, but the only examples I tried to come up with were
pretty sub-optimal, so I don't worry about that any more.)
-- 
--Guido van Rossum (python.org/~guido)
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to