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 paul.moore
Recipients dirn, eric.smith, gregory.p.smith, paul.moore, serhiy.storchaka, steven.daprano, xtreak
Date 2019-05-02.19:41:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
> So the question is: how do you get repr by default, but allow the format spec?
> The only thing I've come up with is:
> - f"{expr!d}" expands to f"expr={repr(expr)}", but
> - f"{expr!d:spec} expands to f"expr={format(expr, spec)}"
> I think this is the most useful version. But is it too complex to explain?

Agreed, this is the most useful version. Not only do I not think it's
too complicated to explain, I actually think it's the obvious
behaviour, and what people would expect even without an explanation.

If asked, I'd explain it as:

    f"{expr!d:spec}" expands to "expr=<the value of expr, formatted
using spec>". If ":spec" is omitted, repr() is used.

That seems simple enough to me - the key is that we're just saying "if
:spec is omitted, we use repr".
Date User Action Args
2019-05-02 19:41:42paul.mooresetrecipients: + paul.moore, gregory.p.smith, eric.smith, steven.daprano, dirn, serhiy.storchaka, xtreak
2019-05-02 19:41:42paul.moorelinkissue36774 messages
2019-05-02 19:41:42paul.moorecreate