Created
May 1, 2015 10:16
-
-
Save Kwpolska/6745cbac68d37ca3a594 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Don’t use this, use itertools.zip_longest() instead! | |
| def alternate_all(*args): | |
| ls = [iter(i) for i in args] | |
| stops = 0 # cheat and get 9 LOC by making this a keyword argument | |
| while stops != len(ls): | |
| stops = 0 | |
| for l in ls: | |
| try: | |
| yield next(l) | |
| except StopIteration: | |
| stops += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment