File size: 1,692 Bytes
598316f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
diff --git a/src/humanize/number.py b/src/humanize/number.py
index 2fb22c6..0b6a6f2 100644
--- a/src/humanize/number.py
+++ b/src/humanize/number.py
@@ -193,7 +193,12 @@ human_powers = (
 )
 
 
-def intword(value: NumberOrString, format: str = "%.1f") -> str:
+def intword(
+    value: NumberOrString,
+    format: str = "%.1f",
+    *,
+    separator: str = " ",
+) -> str:
     """Converts a large integer to a friendly text representation.
 
     Works best for numbers over 1 million. For example, 1_000_000 becomes "1.0 million",
@@ -223,6 +228,7 @@ def intword(value: NumberOrString, format: str = "%.1f") -> str:
         value (int, float, str): Integer to convert.
         format (str): To change the number of decimal or general format of the number
             portion.
+        separator (str): Text inserted between the number and scale word.
 
     Returns:
         str: Friendly text representation as a string, unless the value passed could not
@@ -230,6 +236,9 @@ def intword(value: NumberOrString, format: str = "%.1f") -> str:
     """
     import math
 
+    if not isinstance(separator, str):
+        raise TypeError("separator must be a string")
+
     try:
         if not math.isfinite(float(value)):
             return _format_not_finite(float(value))
@@ -264,7 +273,7 @@ def intword(value: NumberOrString, format: str = "%.1f") -> str:
     unit = _ngettext(singular, plural, math.ceil(rounded_value))
     decimal_sep = decimal_separator()
     number = (format % rounded_value).replace(".", decimal_sep)
-    return f"{negative_prefix}{number} {unit}"
+    return f"{negative_prefix}{number}{separator}{unit}"
 
 
 def apnumber(value: NumberOrString) -> str: