I have a generator that I'd like to be yielded.
def foo():
a = map(lambda x: x*2, range(5))
# I want a better way to the next few lines
# The one that looks more functional
for i in a:
yield i
I have maps, filters etc. That I'd like to be yielded, is there an alternative way to do it? I looked in itertools
and functools
, I couldn't find anything.
Edit:
To be more clearer, I want a way such that it returns one value at each function call.