I have this problem statement:
For optimal performance, records should be processed in batches. Create a generator function "batched" that will yield batches of 1000 records at a time and can be used as follows:
for subrange, batch in batched(records, size=1000):
print("Processing records %d-%d" %(subrange[0], subrange[-1]))
process(batch)
I have tried like this:
def myfunc(batched):
for subrange, batch in batched(records, size=1000):
print("Processing records %d-%d" %
(subrange[0], subrange[-1]))
yield(batched)
But I'm not sure, since I'm new into python generators, this simply doesn't show anything on the console, no error, nothing, any ideas?
batchedlike you are doing.