[Python-Dev] PEP 498: Literal String Interpolation is ready for pronouncement

Eric V. Smith eric at trueblade.com
Sat Sep 5 22:43:52 CEST 2015


On 9/5/2015 12:18 PM, Guido van Rossum wrote:
> On Sat, Sep 5, 2015 at 2:10 AM, haypo s <victor.stinner at gmail.com
> <mailto:victor.stinner at gmail.com>> wrote:
>
>     (is it possible to indent and comment code inside a f-string?)
> 
> 
> Now that's an interesting question. I think the answer must be No,
> because we don't want to deal with ambiguities like whether a closing
> curly bracket or string quote should be ignored inside such comments.
> The processing of f-strings described by the PEP uses several phases:

I'll update the PEP to say comments aren't allowed. It gets especially
wacky when adding () around the expression: f'{2#}' would become the
expression "(2#)", which is a syntax error.

Eric.


More information about the Python-Dev mailing list