def escape_str(escape_str_func, fmt: str, *args) ->str:
    """
    Applies escape_func() to all items of `args' and returns a string based
    on format string `val'.
    """
    escaped_args = map(escape_str_func, args)
    return fmt % tuple(escaped_args)
