Michal Privoznik <mprivozn(a)redhat.com> [2019-11-26, 09:48AM +0100]:
That's exactly what I find horrible. Just consider the following
example:
print(f'a={f(x,n):d}, b={g(x,n):d}')
IMO the following is more readable:
print("a=%d, b=%d" % (f(x,n), g(x,n)))
First of all, the format specifiers (i.e, ":d") are completely optional
if you just care about the string representation of an object.
Secondly, I certainly hope that such code never passes code review
anywhere. Properly cleaning this up to
a = f(x,n)
b = g(x,n)
print(f"a={a}, b={b}")
is much more readable then the old-style
print("a=%d, b=%d" % (a, b))
or even the .format-style
print("a={}, b={}".format(a, b))
Also, format strings have the best performance for string interpolation
in python which is a non-bikeshed argument for them.
Bjoern
--
IBM Systems
Linux on Z & Virtualization Development
--------------------------------------------------
IBM Deutschland Research & Development GmbH
Schönaicher Str. 220, 71032 Böblingen
Phone: +49 7031 16 1819
--------------------------------------------------
Vorsitzende des Aufsichtsrats: Matthias Hartmann
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294