Author eric.smith
Recipients crwilcox, eric.smith, jitterman, zach.ware
Date 2020-02-11.07:18:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I always use datetime for testing such things. Its __format__() returns its argument, as long as you don't have '%' in it.

I do agree that it's odd that the doubled braces cause the expression to be evaluated, but are still kept as single braces in the resulting string. I'll have to investigate, although I'm not sure if we can change it at this point. Surely someone, somewhere is relying on this behavior.

I'll assume that what the OP wants in my example below is a format specifier of "x{x}x":

>>> x = 42
>>> import datetime
>>> now =

>>> f'{now:x{{x}}x}'

Given the current behavior, I'm not sure it's possible to get 'x{x}x'. Sometimes nested f-strings will help, but I don't think that will work here. The OP might need to use a separate expression to calculate the format specifier, which I realize isn't a very satisfying solution.

>>> spec = 'x{x}x'
>>> f'{now:{spec}}'
Date User Action Args
2020-02-11 07:18:24eric.smithsetrecipients: + eric.smith, zach.ware, jitterman, crwilcox
2020-02-11 07:18:24eric.smithsetmessageid: <>
2020-02-11 07:18:24eric.smithlinkissue39601 messages
2020-02-11 07:18:23eric.smithcreate