I am looking for a nice way to zip several iterables raising an exception if the lengths of the iterables are not equal.
zip
In the case where the iterables
Use more_itertools.zip_equal (v8.3.0+):
Code
import more_itertools as mit
Demo
list(mit.zip_equal(range(3), "abc")) # [(0, 'a'), (1, 'b'), (2, 'c')] list(mit.zip_equal(range(3), "abcd")) # UnequalIterablesError
more_itertools is a third party package installed via λ pip install more_itertools
λ pip install more_itertools