What is the use of the yield keyword in Python? What does it do?
For example, I'm trying to understand this code (**):
def node._get_child_candidates(self, distance, min_dist, max_dist):
if self._leftchild and distance - max_dist < self._median:
if self._rightchild and distance + max_dist >= self._median:
And this is the caller:
result, candidates = list(), [self]
node = candidates.pop()
distance = node._get_dist(obj)
if distance <= max_dist and distance >= min_dist:
candidates.extend(node._get_child_candidates(distance, min_dist, max_dist))
What happens when the method _get_child_candidates is called? A list is returned? A single element is returned? Is it called again? When subsequent calls do stop?