Python Forum

Full Version: recursion as a generator
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i have a function that calls itself recursively. i want to make it be a generator. how would that complicate things?
You just have to yield from the same function/generator. Or just yield if there are some conditions to be taken into consideration.
def my_gen(args):
    # some actions
    yield from my_gen(args)