[Python-ideas] Allow parentheses to be used with "with" block
MRAB
python at mrabarnett.plus.com
Mon Feb 16 02:59:01 CET 2015
On 2015-02-15 23:47, Ben Finney wrote:
> MRAB <python at mrabarnett.plus.com> writes:
>
>> For example, how do you distinguish between:
>>
>> with (as a b):
>
> That's ‘with (a as b):’, I think you mean.
>
Correct.
>> and:
>>
>> with (a) as b:
>
> Are we expecting those two to have different effects?
>
That's not the question. The question is how easy they are to
distinguish between when parsing.
A longer example is:
with (a) as b, c as d:
versus:
with (a as b, c as d):
Imagine you've just parsed the 'with'. You know that it's followed by
an expression, and that an expression can start with '(', but now
you're saying that the '(' could also be the start of multiple
as-expressions. How can you tell one are you parsing?
The problem doesn't occur when parsing an 'import' statement because
_that_ doesn't use parentheses otherwise.
More information about the Python-ideas
mailing list