Python Forum
recursion as a generator - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: recursion as a generator (/thread-23982.html)



recursion as a generator - Skaperen - Jan-25-2020

i have a function that calls itself recursively. i want to make it be a generator. how would that complicate things?


RE: recursion as a generator - wavic - Jan-26-2020

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)