def names_in_dir(dir_name, extension):
    """
    Return a sorted list of file names with a particular extension in a
    directory. The extension is not included in the filenames, and files
    starting with underscores are ignored.
    """
    # Find names using glob
    names = [x.name for x in dir_name.glob('[!_]*{}'.format(extension))]
    # Clean up and return
    names = [name.replace(extension, '') for name in names]
    names = sorted(names)
    return names