Add thousands separator

Python pattern

Add thousands separator (1_000_000) to numbers (ints and floats, positive or negative).


Apply with the Grit CLI
grit apply thousands_separator

Add thousands separator to number

BEFORE
for n in range(1000):
    pass

n = -1000 - 2000
n = 1000000000
n = 123456789123456

x = 1000.123
x = 1000000000.123
x = -123456789123456.123

m = 1000000000000000

# Left as is

n = 999
x = 999.0
AFTER
for n in range(1_000):
    pass

n = -1_000 - 2_000
n = 1_000_000_000
n = 123_456_789_123_456

x = 1_000.123
x = 1_000_000_000.123
x = -123_456_789_123_456.123

m = 1000_000_000_000_000

# Left as is

n = 999
x = 999.0