Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
A Python library to print numbers in human readable format
pip install readable-number
This library does not depend on any third-party libraries, so installing it will not break your Python environment.
from readable_number import ReadableNumber
str(ReadableNumber(-1.23)) # -1.23
str(ReadableNumber(-123)) # -123
Print many numbers with the same config:
rn = ReadableNumber(precision=2, digit_group_size=4)
rn.of(123456789) # 1,2345,6789
rn.of(0.123456789) # 0.12
rn.of(1e15) # 1000,0000,0000,0000
str(ReadableNumber(-123)) # -123
str(ReadableNumber(-1234)) # -1,234
str(ReadableNumber(-123456789)) # -123,456,789
str(ReadableNumber(-12345.6789)) # -12,345.6789
str(ReadableNumber(-1.23456e18)) # -1,234,560,000,000,000,000
str(ReadableNumber(-123456789, digit_group_size=4)) # -1,2345,6789
str(ReadableNumber(-123456789, digit_group_delimiter='|')) # -123|456|789
str(ReadableNumber(12345, use_shortform=True)) # 12k
str(ReadableNumber(12345, use_shortform=True, precision=1)) # 12.3k
str(ReadableNumber(12345678, use_shortform=True)) # 12M
str(ReadableNumber(12345678, use_shortform=True, precision=2)) # 12.35M
str(ReadableNumber(1234567890, use_shortform=True, precision=2)) # 1.23B
Numbers are printed in a "natural" way:
str(ReadableNumber(0.12345)) # 0.12345
str(ReadableNumber(0.0000012345)) # 0.0000012345
str(ReadableNumber(0.12345, precision=None)) # 0.12345
str(ReadableNumber(0.12345, precision=2)) # 0.12
str(ReadableNumber(0.12345, precision=20)) # 0.123450000000000
str(ReadableNumber(0.12345, significant_figures_after_decimal_point=3)) # 0.123
str(ReadableNumber(12345, significant_figures_after_decimal_point=3)) # 12,345
str(ReadableNumber(0.00012345, significant_figures_after_decimal_point=3)) # 0.000123
str(ReadableNumber(-1.2345e-50, significant_figures_after_decimal_point=3))
# -0.0000000000000000000000000000000000000000000000000123
str(ReadableNumber(1234567890, use_exponent_for_large_numbers=True)) # 1.234568e+09
str(ReadableNumber(
1234567890,
use_exponent_for_large_numbers=True,
precision=2,
)) # 1.23e+09
str(ReadableNumber(
1234567890,
use_exponent_for_large_numbers=True,
precision=None,
)) # 1.23456789e+09
str(ReadableNumber(
1234567890,
use_exponent_for_large_numbers=True,
large_number_threshold=1e20, # only show in exp if we exceed this
precision=None,
)) # 1,234,567,890
str(ReadableNumber(
1234567890,
use_exponent_for_large_numbers=True,
large_number_threshold=1e20, # only show in exp if we exceed this
significant_figures_after_decimal_point=5,
)) # 1.2346e+09
str(ReadableNumber(0.000000012, use_exponent_for_small_numbers=True)) # 1.200000e-08
str(ReadableNumber(
-0.000000123456,
use_exponent_for_small_numbers=True,
precision=2,
)) # -1.23e-07
str(ReadableNumber(
-0.000012345,
use_exponent_for_small_numbers=True,
precision=None,
small_number_threshold=1e-2,
)) # -1.2345e-05
str(ReadableNumber(
-0.00000012345,
use_exponent_for_small_numbers=True,
significant_figures_after_decimal_point=2,
)) # -1.23e-07
Please visit this site: https://readable-number.readthedocs.io/en/stable/
FAQs
A Python library to print numbers in human readable format
We found that readable-number demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.