def legalize_name(name):
    """
    Replace illegal variable name characters with underscore.
    """
    legal_name = ''
    for char in name:
        if char in '.-':
            char = '_'
        legal_name += char
    return legal_name