[Python-Dev] Easier debugging with f-strings
Tim Peters
tim.peters at gmail.com
Tue May 7 12:50:54 EDT 2019
More information about the Python-Dev mailing list
Tue May 7 12:50:54 EDT 2019
- Previous message (by thread): [Python-Dev] Easier debugging with f-strings
- Next message (by thread): [Python-Dev] Easier debugging with f-strings
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Larry Hastings <larry at hastings.org>] > Guido just stopped by--we're all at the PyCon 2019 dev sprints--and we had > a chat about it. Guido likes it but wanted us to restore a little of the magical > behavior we had in "!d": now, = in f-strings will default to repr (!r), unless > you specify a format spec. If you specify a format spec it will always default > to format. And naturally if you specify an explicit conversion function (!r !s !a) > it will use that. > > This makes !f irrelevant, so we're removing it. > > Here's the thinking: 99% of the time the user will just use {foo=}, and for that > you want repr. After that, 0.99% of the time the user will want a format spec > that applies directly the value. It's exceedingly unlikely that someone will > want a format spec, but want it to apply to repr(value) and not value itself. So > that's possible (f'{foo=!r:20}'). But the default behavior is the most common > case at every step. +1. Perfect! I'm one of the 0.99% who will frequently use this to display floats, and really wants them to show as "0.99%" rather than "0.9913499340289%". BTW, that Guido person has made enough decent contributions by now that I think he should be asked whether he wants to become a core dev!
- Previous message (by thread): [Python-Dev] Easier debugging with f-strings
- Next message (by thread): [Python-Dev] Easier debugging with f-strings
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list