Browse code

add 'named_product' function

Bas Nijholt authored on 13/06/2018 01:23:09
Showing 1 changed files
... ...
@@ -1,5 +1,12 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 from contextlib import contextmanager
3
+from functools import partial
4
+
5
+
6
+def named_product(**items):
7
+    names = items.keys()
8
+    vals = items.values()
9
+    return [dict(zip(names, res)) for res in product(*vals)]
3 10
 
4 11
 
5 12
 @contextmanager