[Python-ideas] with-statement syntactic quirk
Eli Bendersky
eliben at gmail.com
Wed Oct 31 13:52:04 CET 2012
On Wed, Oct 31, 2012 at 5:45 AM, Devin Jeanpierre <jeanpierreda at gmail.com>wrote:
> 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
> "context-sensitive" !
>
I use the two as rough synonyms. Shouldn't I?
> 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 (...) :".
>
If this gets accepted, then, is there a reason to stop at "with"? Why not
ignore newlines between "if" and its trailing ":" as well? [playing devil's
advocate here]
Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121031/3a623f00/attachment.html>
More information about the Python-ideas
mailing list