Message 341694 - Python tracker

Message341694

Author serhiy.storchaka
Recipients barry, eric.smith, larry, levkivskyi, serhiy.storchaka
Date 2019-05-07.07:52:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1557215521.88.0.53464805901.issue36817@roundup.psfhosted.org>
In-reply-to
Content
You can use f'*{n=!r:30}*' if you want to format the result of the repr.

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. 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}*".

There is not too much more magic here: if both converter and format specifier are omitted use !r because it is a common special case. I think it is better than the other difference in the default converter used for debugging and normal formatting.
History
Date User Action Args
2019-05-07 07:52:01serhiy.storchakasetrecipients: + serhiy.storchaka, barry, larry, eric.smith, levkivskyi
2019-05-07 07:52:01serhiy.storchakasetmessageid: <1557215521.88.0.53464805901.issue36817@roundup.psfhosted.org>
2019-05-07 07:52:01serhiy.storchakalinkissue36817 messages
2019-05-07 07:52:01serhiy.storchakacreate