I have a generator generator
and also a convenience method to it - generate_all
.
def generator(some_list):
for i in some_list:
yield do_something(i)
def generate_all():
some_list = get_the_list()
return generator(some_list) # <-- Is this supposed to be return or yield?
Should generate_all
return
or yield
? I want the users of both methods to use it the same, i.e.
for x in generate_all()
should be equal to
some_list = get_the_list()
for x in generate(some_list)
No comments:
Post a Comment