[Python-ideas] Briefer string format

Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Jul 21 03:39:46 CEST 2015


On Mon, Jul 20, 2015 at 4:20 PM, Eric V. Smith <eric at trueblade.com> wrote:

> And thinking about it yet some more, I think the easiest and most
> consistent thing to do would be to translate it like:
>
> f'{a[0]}{b[c]}' == '{[0]}{[c]}'.format(a, b)
>

I think Python can do more at compile time and translate

f"Result1={expr1:fmt1};Result2={expr2:fmt2}"

to bytecode equivalent of

"Result1=%s;Result2=%s" %
((expr1).__format__(fmt1), (expr2).__format__(fmt2))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150720/dcf300cf/attachment-0001.html>


More information about the Python-ideas mailing list