> Even if all the arguments are re-iterable containers the recursive call > produces a lazy generator object - the cartesian product of the tail. I > don't want to read it eagerly into a list. And I wasn't proposing that. def cartesian(*sequences): if len(sequences) == 0: yield [] else: head, tail = sequences[:-1], sequences[-1] tail = list(tail) # <--- This is what I was proposing for x in cartesian(*head): for y in tail: yield x + [y] --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4