I am having an issue with iterating over a list of callables in python. The callables are supposed to be called on a generator of strings. The current behaviour is that the last callable in the list is called as many times as there are callables in the list. My current code:
for m in list_of_callables:
strings = (m(s) for s in strings)
In the above code strings is initially of type 'Generator'. I have also tried the following:
for i in range(len(list_of_callables)):
strings = (list__of_callables[i](s) for s in strings)
This has not worked either, but when I don't loop over the callables and simply call them it works just fine:
strings = (list_of_callables[0](s) for s in strings)
strings = (list_of_callables[1](s) for s in strings)
This seems strange to me as the above should be equivalent to the for loop.
Thanks in advance for your help and suggestions :).