Re: [PATCH] check-symfile: Use pythonesque string formatting instead of perl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michal Privoznik <mprivozn@xxxxxxxxxx> [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

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux