[Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)
Ethan Furman
ethan at stoneleaf.us
Fri Apr 13 09:29:05 EDT 2018
On 04/13/2018 06:18 AM, Steven D'Aprano wrote:
> On Fri, Apr 13, 2018 at 09:56:35PM +1000, Chris Angelico wrote:
> If we agree that the benefit of putting the expression first is
> sufficiently large, or that the general Pythonic look of "expr as name"
> is sufficiently desirable (it just looks and reads nicely), then we can
> afford certain compromises. Namely, we can rule that:
>
> except expr as name:
> with expr as name:
>
> continue to have the same meaning that they have now and never mean
> assignment expressions. Adding parens should not change that.
+1
> In other words, the rule is that "expr as name" keeps its current, older
> semantics in with and except statements, and NEVER means the new, PEP
> 572 assignment expression.
>
> Yes, that's a special case that breaks the rules, and I accept that it
> is a point against "as". But the Zen is a guideline, not a law of
> physics, and I think the benefits of "as" are sufficient that even
> losing a point it still wins.
+1
>> 2) Forbid any use of "(expr as name)" in the header of a 'with' statement
>
> You can't forbid it, because it is currently allowed syntax (albeit
> currently without the parens). So the rule is, it is allowed, but it
> means what it meant pre-PEP 572.
+1
> If people agree with me that it is important to put the expression first
> rather than the target name, then the fact that statements and for loops
> put the name first shouldn't matter.
+1 to expression coming first! ;)
--
~Ethan~
More information about the Python-ideas
mailing list