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 eric.smith
Recipients barry, eric.smith, larry, levkivskyi, serhiy.storchaka
Date 2019-05-07.08:17:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1557217070.22.0.961332864006.issue36817@roundup.psfhosted.org>
In-reply-to
Content
> In you example the format spec is applied to both the value and the literal representation of the expression. Is it an error? I do not think this is an expected behavior.

No, you're misreading it. I admit that my example wasn't great. Try this one:

>>> for n in nums:
...   print(f'*{n=:+<30}*')
... 
*n=0.3333333333333333++++++++++++*
*n=1.0+++++++++++++++++++++++++++*
*n=10.0++++++++++++++++++++++++++*
*n=3.141592653589793+++++++++++++*

> If you want to apply it to both the literal expression and its value you can use the nested f-string: f"*{f'{n=}':30}*".

Correct. There's a similar discussion in issue36774.
History
Date User Action Args
2019-05-07 08:17:50eric.smithsetrecipients: + eric.smith, barry, larry, serhiy.storchaka, levkivskyi
2019-05-07 08:17:50eric.smithsetmessageid: <1557217070.22.0.961332864006.issue36817@roundup.psfhosted.org>
2019-05-07 08:17:50eric.smithlinkissue36817 messages
2019-05-07 08:17:50eric.smithcreate