<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr"><span></span></div><div dir="ltr"><meta http-equiv="content-type" content="text/html; charset=utf-8"><div dir="ltr"><span></span></div><div dir="ltr"><meta http-equiv="content-type" content="text/html; charset=utf-8"><br><div dir="ltr">On Oct 4, 2018, at 6:24 PM, Tim Peters <<a href="mailto:tim.peters@gmail.com">tim.peters@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div class="gmail_quote">[Tim]<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> Note that transforming<br>
> <br>
>     {EXPR!d:FMT}<br>
> <br>
> into<br>
> <br>
>     EXPR={repr(EXPR):FMT}<br>
> <br>
> is actually slightly more involved than transforming it into<br>
> <br>
>     EXPR={EXPR:FMT}<br>
> <br>
> so I don't buy the argument that the original idea is simpler.  More <br>
> magical and less useful, yes ;-)<br></blockquote><div><br><div class="gmail_quote"><div dir="ltr">[Eric V. Smith]<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Actually, my proposal is to apply FMT to the entire result of </blockquote></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
EXPR={repr(EXPR)}, not just the repr(EXPR) part. I'm not sure either is <br>
particularly useful.<br></blockquote></div></div></div></blockquote><div><br></div>I think I’ve come around to Tim’s way of thinking on this. If the format spec is basically useless (which I think it would be if it applied to either the whole string or to the repr of the value), then what’s the point of allowing it? I also want the 90% case to be addressed by just plain repr. </div><div dir="ltr"><br></div><div dir="ltr">I did consider (and implement) a version that prohibited format specs, but it seemed wrong to remove a feature that might have some clear use. </div><div dir="ltr"><br></div><div dir="ltr">So, my compromise is:</div><div dir="ltr"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div dir="ltr"><span style="background-color: rgba(255, 255, 255, 0);">- f"{expr!d}" expands to f"expr={repr(expr)}", but </span></div><div dir="ltr"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div dir="ltr"><span style="background-color: rgba(255, 255, 255, 0);">- f"{expr!d:spec} expands to f"expr={format(expr, spec)}"</span></div><div dir="ltr"><div><br></div><div>There’s some more discussion here:</div><div><br></div><div><a href="https://bugs.python.org/issue36774#msg341306">https://bugs.python.org/issue36774#msg341306</a></div><div><br></div><div>As Paul Moore says on that issue, this is explained as: use repr, unless you specify a format spec, then use format. </div><div><br><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div class="gmail_quote">BTW, I checked, and I've never used !r, !s, or !a.  So the idea that the format could apply to a string - when EXPR itself doesn't evaluate to a string - is simply foreign to me.  I suppose it's natural to people who do use ![rsa] all the time - if such people exist ;-)<br></div></div></div></blockquote><br></div><div>Especially when debugging and logging, I use !r all the time. </div><div><br></div><div>Eric</div><div><br></div></div></div></body></html>