]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
argparse howto: Use f-string in preference to "...".format() (#98883)
authorSkip Montanaro <skip.montanaro@gmail.com>
Thu, 3 Nov 2022 02:08:08 +0000 (21:08 -0500)
committerGitHub <noreply@github.com>
Thu, 3 Nov 2022 02:08:08 +0000 (19:08 -0700)
Doc/howto/argparse.rst

index f3ad117a3d3bc6612f3edf6a292bcadf6e5ef548..f4d08e75d946422030cb37581232f6087c516880 100644 (file)
@@ -761,9 +761,9 @@ your program, just in case they don't know::
    if args.quiet:
        print(answer)
    elif args.verbose:
-       print("{} to the power {} equals {}".format(args.x, args.y, answer))
+       print(f"{args.x} to the power {args.y} equals {answer}")
    else:
-       print("{}^{} == {}".format(args.x, args.y, answer))
+       print(f"{args.x}^{args.y} == {answer}")
 
 Note that slight difference in the usage text. Note the ``[-v | -q]``,
 which tells us that we can either use ``-v`` or ``-q``,