I wrote a function to return a generator containing every unique combination of sub-strings a given length that contain more than n elements from a primary string.
A
I thought that a generator would precede as far down the recursion hole as necessary until it hit the yield statement
It will recurse fine, but to get the yield
ed value to propogate back outward, you need to do it explicitly - just like if it was a return
, you would need to explicitly return
the result of each recursion. So, instead of:
self.get_next_probe(new_list, probes, unit_length)
You would do something like:
for val in self.get_next_probe(new_list, probes, unit_length):
yield val
Or if you're using Python 3.3 or newer, you can also do this:
yield from self.get_next_probe(new_list, probes, unit_length)