Paul Moore <p.f.mo...@gmail.com> added the comment:

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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36774>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to