def human_size(bytes):
    """Return number of bytes as string with most appropriate unit."""
    if bytes == 0:
        return '0 B'
    suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'YB']
    bytes = float(bytes)
    i = 0

    while bytes >= 1024 and i < (len(suffixes) - 1):
        bytes /= 1024.0
        i += 1

    if i > 2:
        f = '{:0.2f}'.format(bytes)
    else:
        f = '{:0.1f}'.format(bytes)

    f = f.rstrip('0').rstrip('.')

    return '{} {}'.format(f, suffixes[i])