From fb612123958913d3c0223348372d44252e4da858 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 15 Mar 2020 15:21:00 -0700 Subject: [PATCH] Add some example calls to bytestring docstring. --- voussoirkit/bytestring.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/voussoirkit/bytestring.py b/voussoirkit/bytestring.py index 61e974a..b29c253 100644 --- a/voussoirkit/bytestring.py +++ b/voussoirkit/bytestring.py @@ -40,7 +40,18 @@ UNIT_SIZES = sorted(UNIT_STRINGS.keys(), reverse=True) def bytestring(size, decimal_places=3, force_unit=None): ''' - Convert a number into string. + Convert a number into a string like "100 MiB". + + >>> bytestring(1000) + '1000 b' + >>> bytestring(1024) + '1.000 KiB' + >>> bytestring(123456) + '120.562 KiB' + >>> bytestring(800000000) + '762.939 MiB' + >>> bytestring(800000000, decimal_places=0) + '763 MiB' force_unit: If None, an appropriate size unit is chosen automatically.