[Python-ideas] with-statement syntactic quirk
jeanpierreda at gmail.com
Wed Oct 31 13:45:00 CET 2012
On Wed, Oct 31, 2012 at 8:33 AM, Eli Bendersky <eliben at gmail.com> wrote:
>> Is there a reason the tokenizer can't ignore newlines and
>> indentation/deindentation between with/etc. and the trailing colon?
>> This would solve the problem in general, without ambiguous syntax.
> At the expense of making the tokenizer context dependent?
It's already context-dependent in some sense, but this wouldn't make
it any moreso. For example, the tokenizer already ignores
indents/dedents when inside parens/braces/brackets, and handling this
only slightly more complex than that. In particular, the trailing
colon is the one not inside braces or brackets.
Also, I'd avoid the term "context-dependent". It sounds too similar to
Anyway, it looks like this isn't how the tokenizer treats
braces/brackets (it ignores indent/dedent, but not newlines (I guess
the grammar handles those)). What I meant to suggest was, treat "with
... :" similarly to how the OP suggests treating "with (...) :".
More information about the Python-ideas