[Python-Dev] PEP 572, VF/B, and "Shark Jumping"
Chris Angelico
rosuav at gmail.com
Wed Jul 4 20:22:54 EDT 2018
On Thu, Jul 5, 2018 at 9:52 AM, Mike Miller <python-dev at mgmiller.net> wrote:
> Compromise:
>
> Fortunately there is a compromise design that is chosen often these days in
> new languages---restricting these assignments to if/while (potentially
> comp/gen) statements. We can also reuse the existing "EXPR as NAME" syntax
> that already exists and is widely enjoyed.
>
> This compromise design:
>
> 1 Handles the most common cases (of a group of infrequent cases)
> 0 Doesn't handle more obscure cases.
> 1 No new syntax (through reuse)
> 1 Looks Pythonic as hell
> 1 Difficult to misuse, complexity capped
>
> Score: 4/5
PLEASE can people stop rehashing this one and go and read previous
discussions and the PEP? Your first point is a failure, not a success
- the "if expr as name:" syntax is able to handle only the tiniest
proportion of cases, because many MANY situations require a condition
after that. You can't write this, for instance:
if f(x) as spam < 0:
print(spam)
So it fails the first, fails the second, is identical on the third
(it's still new syntax, just reusing a keyword - that's no better than
":="), is dubious on the fourth (Python uses "as NAME" for things that
are quite different from this, so it's confusing), and scores a
definite win only on the fifth - it's hard to misuse because it's
nerfed to oblivion.
This is old news. It's not a compromise design - it's a failed
previous iteration that is already mentioned in the PEP.
ChrisA
More information about the Python-Dev
mailing list