def _NameToIndex(name, L):
    """Return index of name in list, appending if necessary

    This routine uses a list instead of a dictionary, because a
    dictionary can't store two different keys if the keys have the
    same value but different types, e.g. 2 and 2L.  The compiler
    must treat these two separately, so it does an explicit type
    comparison before comparing the values.
    """
    t = type(name)
    for i, item in enumerate(L):
        if t == type(item) and item == name:
            return i
    end = len(L)
    L.append(name)
    return end