@@ -0,0 +1,7 @@
+---
+icon: package
+label: itertools
+
+### `itertools.zip_longest(a, b)`
@@ -0,0 +1,13 @@
+def zip_longest(a, b):
+ a = iter(a)
+ b = iter(b)
+ while True:
+ ai = next(a)
+ bi = next(b)
+ if ai is StopIteration and bi is StopIteration:
+ break
+ if ai is StopIteration:
+ ai = None
+ if bi is StopIteration:
+ bi = None
+ yield ai, bi
@@ -1606,6 +1606,7 @@ void VM::post_init(){
_lazy_modules["typing"] = kPythonLibs_typing;
_lazy_modules["datetime"] = kPythonLibs_datetime;
_lazy_modules["cmath"] = kPythonLibs_cmath;
+ _lazy_modules["itertools"] = kPythonLibs_itertools;
try{
CodeObject_ code = compile(kPythonLibs_builtins, "<builtins>", EXEC_MODE);
@@ -0,0 +1,6 @@
+from itertools import zip_longest
+a = [1, 2, 3]
+b = [2]
+assert list(zip_longest(a, b)) == [(1, 2), (2, None), (3, None)]