]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
argparse howto: Use f-string in preference to "...".format() (GH-98883)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 3 Nov 2022 02:17:33 +0000 (19:17 -0700)
committerGitHub <noreply@github.com>
Thu, 3 Nov 2022 02:17:33 +0000 (19:17 -0700)
(cherry picked from commit 1fd20d0b57478d8b0d8d58718fa773135348bf98)

Co-authored-by: Skip Montanaro <skip.montanaro@gmail.com>
Doc/howto/argparse.rst

index a97d10cfe6bb6902c0b927eda2bb5556cebbbe8a..adc2f37371a91a01f34d8ed737f3f38b4328fb45 100644 (file)
@@ -732,9 +732,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``,