Skip to content

Commit

Permalink
Merge pull request #285 from neutrinoceros/rfc/fstrings_formatters
Browse files Browse the repository at this point in the history
RFC: rewrite a complicated string formatting operation with an fstring
  • Loading branch information
neutrinoceros authored Nov 27, 2024
2 parents 3beac12 + a188765 commit ad1849e
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 ad1849e

Please sign in to comment.