Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

humanreadable is a Python library to convert from human-readable values to Python values.

Project description


humanreadable is a Python library to convert from human-readable values to Python values.

PyPI package version Linux CI status Test coverage

Supported Unites

  • time (days, hours, minutes, seconds, …)
  • bit per seconds


Basic usages

Sample Code:
import humanreadable as hr

print("\n[Examples: humanreadable.Time]")
value = "120 sec"
print("'{}' to msecs -> {}".format(value, hr.Time(value).milliseconds))
print("'{}' to minutes -> {}".format(value, hr.Time(value).minutes))

print("\n[Examples: humanreadable.BitPerSecond]")
value = "1 Gbps"
print("'{}' to Mbps -> {}".format(value, hr.BitPerSecond(value).mega_bps))
print("'{}' to Kbps -> {}".format(value, hr.BitPerSecond(value).kilo_bps))
print("'{}' to Kibps -> {}".format(value, hr.BitPerSecond(value).kibi_bps))
[Examples: humanreadable.Time]
'120 sec' to msecs -> 120000.0
'120 sec' to minutes -> 2.0

[Examples: humanreadable.BitPerSecond]
'1 Gbps' to Mbps -> 1000.0
'1 Gbps' to Kbps -> 1000000.0
'1 Gbps' to Kibps -> 953674.31640625

Set default unit

Sample Code:
import humanreadable as hr

print(hr.Time("1", default_unit=hr.Time.Unit.SECOND))
1.0 seconds


Available units for humanreadable.Time
Unit Available specifiers (str)
days d/day/days
hours h/hour/hours
minutes m/min/mins/minute/minutes
seconds s/sec/secs/second/seconds
milliseconds ms/msec/msecs/millisecond/milliseconds
microseconds us/usec/usecs/microsecond/microseconds
Available units for humanreadable.BitPerSecond
Unit Available specifiers (str)
bps bps/bit/s
Kbps [kK]bps/[kK]bit/s
Kibps [kK]ibps/[kK]ibit/s
Mbps [mM]bps/[mM]bit/s
Mibps [mM]ibps/[mM]ibit/s
Gbps [gG]bps/[gG]bit/s
Gibps [gG]ibps/[gG]ibit/s
Tbps [tT]bps/[tT]bit/s
Tibps [tT]ibps/[tT]ibit/s


Install from PyPI

pip install humanreadable

Install from PPA (for Ubuntu)

sudo add-apt-repository ppa:thombashi/ppa
sudo apt update
sudo apt install python3-humanreadable


Python 2.7+ or 3.5+

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for humanreadable, version 0.0.7
Filename, size File type Python version Upload date Hashes
Filename, size humanreadable-0.0.7-py2.py3-none-any.whl (8.9 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size humanreadable-0.0.7.tar.gz (10.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page