Skip to content

Commit

Permalink
RFC: rewrite a complicated string formatting operation with an fstring
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Nov 27, 2024
1 parent 3beac12 commit a188765
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/inifix/enotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ def encode(r: float, /) -> str:
return "0e0"
max_ndigit = len(base.replace(".", "")) - 1
fmt = f".{max_ndigit}e"
s = "{:^{}}".format(r, fmt)
return ENotationIO.simplify(s)
return ENotationIO.simplify(f"{r:{fmt}}")

@staticmethod
def encode_preferential(r: float, /) -> str:
Expand Down

0 comments on commit a188765

Please sign in to comment.