Suppose I have a list that I wish not to return but to yield values from. What is the most Pythonic way to do that?
Here is what I mean. Thanks to some non-lazy computation I have computed the list ['a', 'b', 'c', 'd']
, but my code through the project uses lazy computation, so I'd like to yield values from my function instead of returning the whole list.
I currently wrote it as following:
List = ['a', 'b', 'c', 'd']
for item in List:
yield item
But this doesn't feel Pythonic to me.
Looking forward to some suggestions, thanks.
Boda Cydo.