Learn to Code ยท zero-dependency ยท MIT

larznum

Human-friendly number formatting.

Numbers that look right make software feel finished: 1,234,567 not 1234567, 3rd not 3, 1.5 MB not 1572864 bytes, 1.2k not 1200. These little formatting jobs are fiddly and no single builtin covers all of them - larznum bundles the everyday ones.

larzscript pkg install num
View on GitHub →Learn the stack

What you get

Try it

import "num" as num
print(num.commas(1234567))
print(num.ordinal(23))
print(num.filesize(1572864))
print(num.abbreviate(3450000))
print(num.percent(0.4567, 1))
Output
1,234,567
23rd
1.5 MB
3.5M
45.7%

Why it's in the Larz Stack

larznum is a real Larzscript package (larzscript pkg install num) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.