This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jitterman
Recipients crwilcox, eric.smith, jitterman, zach.ware
Date 2020-02-11.21:56:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1581458216.79.0.838479506889.issue39601@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-02-11 21:56:56jittermansetrecipients: + jitterman, eric.smith, zach.ware, crwilcox
2020-02-11 21:56:56jittermansetmessageid: <1581458216.79.0.838479506889.issue39601@roundup.psfhosted.org>
2020-02-11 21:56:56jittermanlinkissue39601 messages
2020-02-11 21:56:56jittermancreate