Nick Coghlan <[email protected]> added the comment:
Especially since the dynamic flexibility of ExitStack comes at a genuine
runtime cost when unwinding the resource stack.
I also (very!) belatedly noticed that I never answered Julian's request for
clarification about the potential grammar ambiguity, so going into detail about
that now:
The first item in the grammar after the 'with' keyword is a 'test' node, which
can already start with a parenthesis, which means a naive attempt at allowing
grouping parentheses will likely fail to generate a valid LL(1) parser.
That doesn't mean a more sophisticated change isn't possible (and Pablo has
apparently implemented one) - it just means that the required grammar update is
going to be more complicated than just changing:
with_stmt: 'with' with_item (',' with_item)* ':' suite
to be:
with_stmt: 'with' (with_items | '(' with_items ')') ':' suite
with_items: with_item (',' with_item)*
(That would need too much lookahead to decide whether an opening parenthesis
belongs to the first 'with_item' in 'with_items' or if it's starting the
alternative multi-line grouping construct)
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue12782>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com