def tabs_to_spaces(line, tab_size=4):
    """Converts tabs to a fixed numbers of spaces at the beginning of a string"""
    spaces = 0
    for c in line:
        if c not in " \t":
            break
        if c == "\t":
            spaces += tab_size - (spaces % tab_size)
        else:
            spaces += 1
    return " " * spaces + line.lstrip()