def _get_elements(lst, type_=float):
    """
    return all first elements of lst that can be converted to type_. Remove them
    from lst.
    """
    r = []
    try:
        while lst:
            e = lst.pop(0)
            e = type_(e)
            r.append(e)
    except ValueError:
        lst.insert(0, e)
    return r
