Skip to content

Commit

Permalink
docs: use f-strings instead format (#585)
Browse files Browse the repository at this point in the history
In the documentation use f-strings in the examples.
  • Loading branch information
damani42 authored Feb 3, 2022
1 parent ba4b1a0 commit 4931a15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ might look like this::
verbose = cli.Flag(["v", "verbose"], help = "If given, I will be very talkative")

def main(self, filename):
print("I will now read {0}".format(filename))
print(f"I will now read {filename}")
if self.verbose:
print("Yadda " * 200)

Expand Down Expand Up @@ -492,7 +492,7 @@ attached to the root application using the ``subcommand`` decorator ::

def main(self, *args):
if args:
print("Unknown command {0!r}".format(args[0]))
print(f"Unknown command {args[0]}")
return 1 # error exit code
if not self.nested_command: # will be ``None`` if no sub-command follows
print("No command given")
Expand Down
4 changes: 2 additions & 2 deletions docs/colorlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ For example, if you wanted to create an HTMLStyle and HTMLcolors, you could do::
result = ''

if self.bg and not self.bg.reset:
result += '<span style="background-color: {0}">'.format(self.bg.hex_code)
result += f'<span style="background-color: {self.bg.hex_code}">'
if self.fg and not self.fg.reset:
result += '<font color="{0}">'.format(self.fg.hex_code)
result += f'<font color="{self.fg.hex_code}">'
for attr in sorted(self.attributes):
if self.attributes[attr]:
result += '<' + self.attribute_names[attr] + '>'
Expand Down

0 comments on commit 4931a15

Please sign in to comment.