On 4 November 2016 at 08:36, Simon Cross <hodgestar+python...@gmail.com> wrote:
> On Fri, Nov 4, 2016 at 9:56 AM, Eric V. Smith <e...@trueblade.com> wrote:
>> 2. The parser sees that it's an f-string, and breaks it into expression and
>> text parts.
>
> I'm with Fabio here. It would be really nice to have a grammar
> specified and documented for this step, even if it's not implemented
> that way. Otherwise it's going to be very hard for, e.g., syntax
> highlighters to know what is intended to be allowed.

I think that if the docs explain the process, essentially as noted by
Eric above:

> Step 2 is the part that limits what types of expressions are allowed.
> While scanning for the end of an expression, it stops at the first '!', ':', 
> or '}' that
> isn't inside of a string and isn't nested inside of parens, braces, and 
> brackets.
[...]
> Also, backslashes are not allowed anywhere inside of the expression.

then that would be fine. Possibly a bit more detail would be helpful,
but I'm pretty sure I could reimplement the behaviour (for a syntax
highlighter, for example) based on the above.

I assume that the open item Eric mentions to fix the PEP and docs is
sufficient to cover this, so it'll be documented in due course.

Paul
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to