def topMatches(prefs,person,n=5,similarity=sim_pearson):
scores=[(similarity(prefs,person,other),other)
for other in prefs if other!=person]
scores.sort()
scores.reverse()
return scores[0:n]
topmatches関数内で別の関数を呼び出しているだけです。他の場所で定義していない他の関数がどのように機能するか疑問です。また、関数topmatchesに渡していないので、 これがどのように機能するか説明できますか?