def size(filename, format='decimal'):
    '''
    Retrieve the size of a file.

    :param filename: name of the file

    >>> size('/etc/mime.types')         # doctest: +SKIP
    23.70 kB

    '''
    if isinstance(filename, file):
        filename = filename.name

    return filesize(os.stat(filename)[stat.ST_SIZE], format)