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.07:32:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> Except that I think that !f is not needed. You can use repr by default only when no format spec is specified, and add explicit !r if you want to use repr with the format spec. If you want to format the value without repr and the format spec -- specify the empty format spec: f"{foo=:}".

I had this working in issue36774, but it seems like a little too much magic. It also prevents you from formatting the result of the repr, which works in f-strings without the =.

Say you wanted a fixed width output. You need to apply a format to the value of the repr:

>>> nums = [1/3, 1.0, 10.0, math.pi]
>>> for n in nums:
...   print(f'*{n=}*')

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

If the presence of a format spec meant automatically apply the format to the value being printed, this wouldn't be possible.
Date User Action Args
2019-05-07 07:32:42eric.smithsetrecipients: + eric.smith, barry, larry, serhiy.storchaka, levkivskyi
2019-05-07 07:32:42eric.smithsetmessageid: <>
2019-05-07 07:32:42eric.smithlinkissue36817 messages
2019-05-07 07:32:42eric.smithcreate