@@ -1894,14 +1894,24 @@ are always available. They are listed here in alphabetical order.
1894
1894
>>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))
1895
1895
[('a', 1), ('b', 2), ('c', 3)]
1896
1896
1897
- Unlike the default behavior, it checks that the lengths of iterables are
1898
- identical, raising a :exc: `ValueError ` if they aren't:
1899
-
1900
- >>> list (zip (range (3 ), [' fee' , ' fi' , ' fo' , ' fum' ], strict = True ))
1897
+ Unlike the default behavior, it raises a :exc: `ValueError ` if one iterable
1898
+ is exhausted before the others:
1899
+
1900
+ >>> for item in zip (range (3 ), [' fee' , ' fi' , ' fo' , ' fum' ], strict = True ): # doctest: +SKIP
1901
+ ... print (item)
1902
+ ...
1903
+ (0, 'fee')
1904
+ (1, 'fi')
1905
+ (2, 'fo')
1901
1906
Traceback (most recent call last):
1902
1907
...
1903
1908
ValueError: zip() argument 2 is longer than argument 1
1904
1909
1910
+ ..
1911
+ This doctest is disabled because doctest does not support capturing
1912
+ output and exceptions in the same code unit.
1913
+ https://github.com/python/cpython/issues/65382
1914
+
1905
1915
Without the ``strict=True `` argument, any bug that results in iterables of
1906
1916
different lengths will be silenced, possibly manifesting as a hard-to-find
1907
1917
bug in another part of the program.
0 commit comments