Subject: Notice- Your score might have been changed

From: Review Your Report <[email-masked]>
Date: Fri, 09 May 2014 10:03:00 -0700

ATTN: Atompub-archive, 
RE: Your Credit Score May have Just Changed

Your credit data may have been compromised due to recent data breaches at institutions that may serve you. 

If you have used a credit card in the past 6 months, you need to check your Credit Score immediately.

View Your Score Now: http://www.zeeresult.com/score/report/available/may09.html

Regards, 

Urgent Info Services

to stop notifications from Urgent Info Services 
-write 3205 Lake Sarah Independence, MN 55359
or http://www.zeeresult.com/vgjek9/sj.fmik

def node._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 
And this is the caller:

result, candidates = list(), [self]
while candidates:
node = candidates.pop()
distance = node._get_dist(obj)
if distance <= max_dist and distance >= min_dist:
result.extend(node._values)
candidates.extend(node._get_child_candidates(distance, min_dist, max_dist))
return result
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?

** The code comes from Jochen Schulz (jrschulz), who made a great Python library for metric spaces. This is the link to the complete source: Module mspace.

Keep calling thenext()method on the iterator returned from step The return value fromnext()is assigned toxand the loop body is executed. If an exceptionStopIterationis raised from withinnext(), it means there are no more values in the iterator and the loop is exited.

The truth is Python performs the above two steps anytime it wants toloop overthe contents of an object - so it could be a for loop, but it could also be code likeotherlist.extend(mylist)(whereotherlistis a Python list).

Heremylistis aniterablebecause it implements the iterator protocol. In a user defined class, you can implement the__iter__()method to make instances of your class iterable. This method should return aniterator. An iterator is an object with anext()method. It is possible to implement both__iter__()andnext()on the same class, and have__iter__()returnself. This will work for simple cases, but not when you want two iterators looping over the same object at the same time.

So that's the iterator protocol, many objects implement this protocol:

Built-in lists, dictionaries, tuples, sets, files.

User defined classes that implement__iter__().

Generators.Note that aforloop doesn't know what kind of object it's dealing with - it just follows the iterator protocol, and is happy to get item after item as it callsnext(). Built-in lists return their items one by one, dictionaries return thekeysone by one, files return thelinesone by one, etc. And generators return... well that's whereyieldcomes in: