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 函数中调用另一个函数, 我怀疑 other 是如何工作的,我没有在别处定义它 我也没有将它传递给函数topmatches, 谁能给我解释一下这是如何工作的?
请您参考如下方法:
other 是 prefs 中每个 record 的列表元素。
