Skip to main content

A simple Python library for human readable file sizes (or anything sized in bytes).

Project description

hurry.filesize

hurry.filesize a simple Python library that can take a number of bytes and returns a human-readable string with the size in it, in kilobytes (K), megabytes (M), etc.

The default system it uses is “traditional”, where multipliers of 1024 increase the unit size:

>>> from hurry.filesize import size
>>> size(1024)
'1K'

An alternative, slightly more verbose system:

>>> from hurry.filesize import alternative
>>> size(1, system=alternative)
'1 byte'
>>> size(10, system=alternative)
'10 bytes'
>>> size(1024, system=alternative)
'1 KB'

A verbose system:

>>> from hurry.filesize import verbose
>>> size(10, system=verbose)
'10 bytes'
>>> size(1024, system=verbose)
'1 kilobyte'
>>> size(2000, system=verbose)
'1 kilobyte'
>>> size(3000, system=verbose)
'2 kilobytes'
>>> size(1024 * 1024, system=verbose)
'1 megabyte'
>>> size(1024 * 1024 * 3, system=verbose)
'3 megabytes'

You can also use the SI system, where multipliers of 1000 increase the unit size:

>>> from hurry.filesize import si
>>> size(1000, system=si)
'1K'

Changes

0.9 (2009-03-11)

  • Initial public release.

Download

Project details


Release history Release notifications | RSS feed

This version

0.9

Download files

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

Source Distribution

hurry.filesize-0.9.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file hurry.filesize-0.9.tar.gz.

File metadata

File hashes

Hashes for hurry.filesize-0.9.tar.gz
Algorithm Hash digest
SHA256 f5368329adbef86accd3bc9490522340bb79260455ae89b1a42c10f63801b9a6
MD5 8549ccd09bb31b5ff1e8e8c1eacc7794
BLAKE2b-256 ee5e16e17bedcf54d5b618dc0771690deda77178e5c310402881c3d2d6c5f27c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page