Last active
December 27, 2020 15:23
-
-
Save carcigenicate/85791d4818d1bf30c9f405ad820c451e 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
def my_zip(*iterables): | |
iters = [iter(i) for i in iterables] | |
while True: | |
try: | |
yield tuple([next(it) for it in iters]) | |
except StopIteration: | |
return |
Thanks. That's quite advanced, and it did work!
Have a nice Holidays!
@danielhao5 No problem, and you as well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@danielhao5
That's a little bit harder since you can't just rely on
StopIteration
being thrown.This is suboptimal, but off the top of my head:
I don't like the fact that it requires potentially two full iterations of
raw
peryield
, but at the moment, I can't think of how you'd differentiate between afill_value
that coincides with legitimate elements of the list, and all the iterables simply being exhausted.