import ntpath


def path_leaf(path):
    """
    Extract the file name from a path.
    If the file ends with a slash, the basename will be empty,
    so the function to deal with it

    Parameters
    ----------
    path : str
        Path of the file

    Returns
    -------
    output : str
        The name of the file
    """
    head, tail = ntpath.split(path)
    output = tail or ntpath.basename(head)
    return output