def batch_iterator(iterator, batch_size) : entry = True while entry : batch = [] while len(batch) < batch_size : try : entry = iterator.next except StopI