import keyword


def safe_names(names):
    """
    Receive a list of names and return a map from names to the corresponding
    safe name to use as a Python variable.
    """
    safe_names = {}
    for name in names:
        safe_names[name] = name + "_" if keyword.iskeyword(name) else name
    if len(safe_names) != len(set(safe_names.values())):
        msg = "collision between escaped field names and given field names"
        raise ValueError(msg + ": %s" % names)
    return safe_names