On 13 April 2018 at 14:18, Steven D'Aprano <st...@pearwood.info> wrote:
> On Fri, Apr 13, 2018 at 09:56:35PM +1000, Chris Angelico wrote:
>> 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
It's not currently allowed:
>>> with (12 as x):
File "<stdin>", line 1
with (12 as x):
SyntaxError: invalid syntax
> (albeit currently without the parens).
Well, yes, but we're talking about *with* the parens.
> So the rule is, it is allowed, but it means what it meant pre-PEP 572.
So it's a syntax error, because that's what it is pre-PEP 572. So it's
allowed, but as a syntax error (which is what "not allowed" means".
Huh? In any event it's a special case, because "with EXPR:" is valid,
and "(12 as x)" is an example of an EXPR, but put these two together
and you're saying you should get a syntax error. (Or if you're not,
you haven't stated what you *are* proposing...) And there's no good
justification for making this a special case (unless you argue in
circles: it's worth being a special case because "as" is a good syntax
for assignment expressions, and "as" is a good syntax because it's
> 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.
I agree that having the expression first is better. And I think that
-> deserves consideration on that basis. I think "as" is *not* a good
option for a "puts the expression first" option, because of the
ambiguities that Chris has explained. But I also think that it's a
relatively minor point, and I have bigger reservations than this about
the PEP, so arguing over this level of detail isn't crucial to me.
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/