[Python-checkins] argparse howto: Use f-string in preference to "...".format() (#98883)

JelleZijlstra webhook-mailer at python.org
Wed Nov 2 22:08:44 EDT 2022


https://github.com/python/cpython/commit/1fd20d0b57478d8b0d8d58718fa773135348bf98
commit: 1fd20d0b57478d8b0d8d58718fa773135348bf98
branch: main
author: Skip Montanaro <skip.montanaro at gmail.com>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-11-02T19:08:08-07:00
summary:

argparse howto: Use f-string in preference to "...".format() (#98883)

files:
M Doc/howto/argparse.rst

diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst
index f3ad117a3d3b..f4d08e75d946 100644
--- a/Doc/howto/argparse.rst
+++ b/Doc/howto/argparse.rst
@@ -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``,



More information about the Python-checkins mailing list