Skip to content

Instantly share code, notes, and snippets.

@LouiS0616
Created May 6, 2019 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LouiS0616/5fad0d110b9e4ba510a5a798e4daee45 to your computer and use it in GitHub Desktop.
Save LouiS0616/5fad0d110b9e4ba510a5a798e4daee45 to your computer and use it in GitHub Desktop.
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