[issue24965] Implement PEP 498: Literal String Formatting

Eric V. Smith report at bugs.python.org
Sun Sep 13 13:39:43 CEST 2015


Eric V. Smith added the comment:

On 9/13/2015 12:21 AM, Martin Panter wrote:
>>>> f"{'{'}"  # Why is this allowed in an outer format expression--
> '{'
>>>> f"{3:{'{'}>10}"  # --but not inside a format specifier?

This is me being lazy about detecting recursion. I'll fix it.

>>>> f"{\x00}"  # It seems this is treated as a null terminator
>   File "<fstring>", line 1
>     (
>     ^
> SyntaxError: unexpected EOF while parsing

This is a byproduct of using PyParser_ASTFromString. I'm not particularly included to do anything about it. Is there any practical use case?

>>>> f"{'s'!\x00:.<10}"  # Default conversion is the null character?
> 's.........'

Yes, that's the default. I'll switch to -1, which I think won't have this issue.

Thanks for the review.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24965>
_______________________________________


More information about the Python-bugs-list mailing list