@@ -1923,14 +1923,24 @@ are always available. They are listed here in alphabetical order.
1923
1923
>>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))
1924
1924
[('a', 1), ('b', 2), ('c', 3)]
1925
1925
1926
- Unlike the default behavior, it checks that the lengths of iterables are
1927
- identical, raising a :exc: `ValueError ` if they aren't:
1928
-
1929
- >>> list (zip (range (3 ), [' fee' , ' fi' , ' fo' , ' fum' ], strict = True ))
1926
+ Unlike the default behavior, it raises a :exc: `ValueError ` if one iterable
1927
+ is exhausted before the others:
1928
+
1929
+ >>> for item in zip (range (3 ), [' fee' , ' fi' , ' fo' , ' fum' ], strict = True ): # doctest: +SKIP
1930
+ ... print (item)
1931
+ ...
1932
+ (0, 'fee')
1933
+ (1, 'fi')
1934
+ (2, 'fo')
1930
1935
Traceback (most recent call last):
1931
1936
...
1932
1937
ValueError: zip() argument 2 is longer than argument 1
1933
1938
1939
+ ..
1940
+ This doctest is disabled because doctest does not support capturing
1941
+ output and exceptions in the same code unit.
1942
+ https://github.com/python/cpython/issues/65382
1943
+
1934
1944
Without the ``strict=True `` argument, any bug that results in iterables of
1935
1945
different lengths will be silenced, possibly manifesting as a hard-to-find
1936
1946
bug in another part of the program.
0 commit comments