Code Explaination: Spelling correction code

Drew olsonas at
Thu Apr 12 04:41:16 CEST 2007

I recently saw this website:

All the code makes sense to me save one line:

def known_edits2(word):
    return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if e2 in

I understand (from seeing a ruby version of the code) that the goal
here is to rerun the edits1 method on each member of the set returned
by running edits1 on the initial word. However, I'm confused how the
for within a for works. Can anyone help shed some light on this for me?

More information about the Python-list mailing list