Created
May 6, 2019 14:23
-
-
Save LouiS0616/5fad0d110b9e4ba510a5a798e4daee45 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
class NamedZip: | |
def __init__(self, dct=None, **kwards): | |
if dct: | |
kwards = {**dct, **kwards} | |
self._names = kwards.keys() | |
self._iters = [ | |
iter(val) for val in kwards.values() | |
] | |
def __iter__(self): | |
return self | |
def __next__(self): | |
return dict(zip( | |
self._names, [next(it) for it in self._iters] | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment