Hi, Tim. Your name came up frequently as a target for this use case. I think we’ve come up with a pretty good solution.
Now if I could only convince my clients to upgrade from 2.7! I’ve heard about these f-string things, and I think I would enjoy using them. Eric > On May 7, 2019, at 12:50 PM, Tim Peters <tim.pet...@gmail.com> wrote: > > [Larry Hastings <la...@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! > _______________________________________________ > Python-Dev mailing list > Python-Dev@python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > https://mail.python.org/mailman/options/python-dev/eric%2Ba-python-dev%40trueblade.com _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com