def _ensure_has_len(seq):
    try:
        len(seq)
    except TypeError:
        return list(seq)
    else:
        return seq
If seq is an iterator, put its values into a list.
dataset/ETHPy150Open pydata/pandas/pandas/indexes/base.py/_ensure_has_len