import pathlib


def this_module_name(short_name: bool = False) -> str:
    """
    By default, module.name includes the package name, like "toolbox.file_util.ez_ftp"
    To include only the last component, e.g "ez_ftp", set short_name = True.
    :param short_name: By default, module.name includes the package name, like
                        "toolbox.file_util.ez_ftp".  To include only the last
                        component, e.g "ez_ftp", set short_name = True.
    :return: the name of this module (str)
    """
    try:
        mod_name = __loader__.name
    except:
        mod_name = pathlib.Path(__file__).stem
    short = __loader__.name.split('.')[-1]
    if __name__ == '__main__':
        result = __loader__.name
    elif __name__ == 'builtins':
        # Do I want to do something special in this case?
        result = __name__
    else:
        result = __name__
    if short_name:
        result = result.split('.')[-1]
    return result