def synchronize_iterables(iterables):
 out_list = []
 iterable_items = [(field, iter(fvals())) for (field, fvals) in sorted(iterables.items())]
 while True:
  cur_dict = {}
  for (field, iter_values) in iterable_items:
   try:
    cur_dict[field] = next(iter_values)
   except StopIteration:
    pass
  if cur_dict:
   out_list.append(cur_dict)
  else:
   break
 return out_list

def synchronize_iterables ( iterables ) : out_list = [ ] iterable_items = [ ( field , iter ( fvals ( ) ) ) for ( field , fvals ) in sorted ( iterables . items ( ) ) ] while True : cur_dict = { } for ( field , iter_values ) in iterable_items : try : cur_dict [ field ] = next ( iter_values ) except StopIteration : pass if cur_dict : out_list . append ( cur_dict ) else : break return out_list
synchronize the given iterables in item-wise order .