JitterMan <pythonb...@shalmirane.com> added the comment: I believe it is worth fixing as it clears up some rather glaring inconsistencies␣ and enables a useful capability. Specifically,
1. Formatted string literals and the string format method are currently inconsistent in the way that they handle double braces in the format specifier. >>> x = 42 >>> import datetime >>> now = datetime.datetime.now() >>> f'{now:x{{x}}x}' 'x{42}x' >>> '{:x{{x}}x}'.format(now) 'x{x}x' 2. Formatted string literals currently seem inconsistent in the way they handle handle doubled braces. In the base string doubling the braces escapes them. >>> f'x{{x}}x' 'x{x}x' In the replacement expression doubling the braces escapes them. >>> f'{f"x{{x}}x"}' 'x{x}x' In the format specifier doubling the braces does not escape them. >>> f'{now:x{{x}}x}' 'x{42}x' 3. Currently there is no way I know of escape the braces in the format specifier. 4. Allowing the braces to be escaped in the format specifier allows the user to defer the interpretation of the of a format specifier so that it is evaluated by a format function inside the object rather than being evaluated in the current context. That seems like a generally useful feature. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39601> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com