On Sun, May 20, 2018 at 4:07 AM, Kirill Balunov <kirillbalu...@gmail.com> wrote: > [Chris] > >> The bit that you tag on as an afterthought is actually critically >> important here. You have two options: >> 1) The 'as' is part of the syntax of the 'if' and 'while' statements; or >> 2) The 'as' is part of the definition of an expression. >> The first case would be grammar like this: >> if_stmt: 'if' test ['as' NAME] ':' suite ('elif' test ':' suite)* >> ['else' ':' suite] >> The second is permitting 'as' name-bindings in arbitrary expressions, >> but then saying "except that they're only allowed in 'if' statements". >> As you've noted, the first one isn't sufficient. You can't use the >> restricted syntax for more than a small handful of conditions >> (including re.match(), but not including anything that might return >> None and might return other falsey values). >> So if this is valid: >> if (f(x) as y) is not None: > > > I think I have a very strong argument "why are not others valid" - Because > already three months have passed and among 1300+ messages there was not a > single real example where assignment expression would be convenient or > useful outside `while` and `if` statements. If you have a counterargument > (with an example), I would be glad to see.
Okay. Let me put it to you this way, then: Write up a simple and easy-to-explain set of rules for exactly what is valid and what is not. Make an actual proposal here. Be sure to demonstrate that the new construct is useful, with examples (like you're asking me for), and be sure that you're thorough enough in your definitions that this could actually be coded. I think you'll find that 1300+ messages aren't enough to adequately define what you're asking for. Or, alternatively: Give up on the 'as' syntax, because it was dropped from the PEP for a reason. ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/