def human_size(bytesize, p=1):
    """ Return human-readable string of n bytes
    Use p to set the precision

    >>> human_size(42424242)
    '40,5 MiB'

    >>> human_size(42424242, 0)
    '40 MiB'

    >>> human_size(1024**3, 2)
    '1024,00 MiB'
    """

    i = 0
    while bytesize > 1024:
        bytesize /= 1024.0
        i += 1

    bytesize = (('%.' + str(p) + 'f') % bytesize).replace('.', ',')
    return '%s %s' % (bytesize, ('b', 'KiB', 'MiB', 'GiB')[i])