Message341313
> 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:42 | paul.moore | set | recipients:
+ paul.moore, gregory.p.smith, eric.smith, steven.daprano, dirn, serhiy.storchaka, xtreak |
2019-05-02 19:41:42 | paul.moore | link | issue36774 messages |
2019-05-02 19:41:42 | paul.moore | create | |
|