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

This commit is contained in:
Skip Montanaro 2022-11-02 21:08:08 -05:00 committed by GitHub
parent c053284e39
commit 1fd20d0b57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View 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``,