From 9abf74cb9bedd3425370d6f96f783770f6dda9dc Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 12 Mar 2020 14:00:38 -0700 Subject: [PATCH] Set decimal_places to 0 when result is in bytes. So that you get "100 b" instead of "100.000 b". --- voussoirkit/bytestring.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/voussoirkit/bytestring.py b/voussoirkit/bytestring.py index cc633e5..48116e6 100644 --- a/voussoirkit/bytestring.py +++ b/voussoirkit/bytestring.py @@ -56,6 +56,9 @@ def bytestring(size, decimal_places=3, force_unit=None): size_unit_string = UNIT_STRINGS[divisor] + if divisor == BYTE: + decimal_places = 0 + size_string = '{number:.0{decimal_places}f} {unit}' size_string = size_string.format( decimal_places=decimal_places,