[Python-ideas] Allow parentheses to be used with "with" block
Paul Moore
p.f.moore at gmail.com
Tue Feb 17 00:46:39 CET 2015
On 16 February 2015 at 21:30, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> How about adopting a version of the dangling-operator
> rule suggested earlier, but *only* for commas?
>
> I think it could be handled entirely in the lexer: if
> you sees a comma followed by a newline, and the next
> line is indented further than the current indentation
> level, absorb the newline and indentation.
>
> This would take care of all the statements I can think
> of that can't currently be parenthesised.
One thing that's not been discussed much here is that *any*
line-continuation rules (even the ones that already exist) make the
interactive interpreter's job harder. I don't know exactly how it
works, and whether there's special code in the REPL for things like
backslash continuation, but interactive use (and in particular error
handling) need to be considered in all this.
As well as the standard interpreter, would new rules like this affect
tools like IPython?
(Maybe all the interactive tools work by magic, and the changes can be
isolated to the parser and lexer. That would be nice, and if so my
above comments are irrelevant. But someone should probably check).
Paul
More information about the Python-ideas
mailing list