ما هو استخدام المفتاح 'yield' ضمن البايثون؟
احاول ان افهم الكود الآتي:
def _get_child_candidates(self, distance, min_dist, max_dist):
if self._leftchild and distance - max_dist < self._median:
yield self._leftchild
if self._rightchild and distance + max_dist >= self._median:
yield self._rightchild
وهذا هو كود المناداة:
result, candidates = [], [self]
while candidates:
node = candidates.pop()
distance = node._get_dist(obj)
if distance &l