I have a strange problem with the return of a recursive function. It always return 'None' instead of the temp_blocks. He will write the temp_blocks (List of blocks, not None) in the else-case, but it seems it doesn't return the list if i call the function blocks = _searchblocks(roots, left_edge, right_edge)
. Is this a common problem, or is it my fault?
def _searchblocks(blocks, left_edge, right_edge):
temp_blocks = []
for block in blocks:
if np.any(block.left_edge >= left_edge) \
and np.any(block.right_edge <= right_edge):
temp_blocks.append(block)
if len(temp_blocks) == 1:
_searchblocks(temp_blocks[0].children, left_edge, right_edge)
else:
print(temp_blocks)
return temp_blocks