Lets say there is a function return_list_from_iterable that takes any iterable as an argument.
def return_list_from_iterable(iterable):
if is_finite(iterable): #check if iterator is finite
return list(iterable)
Is there a way to check if iterator is fininite before calling list(iterable), e.g if to pass itertools.repeat('hello, infinity!') as an argument then, i guess, something bad can happen while the function is running.