From a188765915ed91cb174c22a29e8a2814847cf56f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Wed, 27 Nov 2024 10:05:37 +0100 Subject: [PATCH] RFC: rewrite a complicated string formatting operation with an fstring --- src/inifix/enotation.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/inifix/enotation.py b/src/inifix/enotation.py index fcf9aef..79c351f 100644 --- a/src/inifix/enotation.py +++ b/src/inifix/enotation.py @@ -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: