Created
August 5, 2014 08:39
-
-
Save quatrix/c50a88364b638194bb5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product | |
def my_product(head, *tail): | |
if not tail: | |
return ((h,) for h in head) | |
return ((h,) + t for h in head for t in my_product(*tail)) | |
if __name__ == "__main__": | |
iterables = [1, 2], ['a', 'b', 'c'], ['vova', False], ['heh', 'lol'] | |
assert list(my_product(*iterables)) == list(product(*iterables)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment