<p>我目前正在用Python编写一个程序来为射影几何建模,而投影点的同余函数看起来相当讨厌。在</p>
<p>(对于任何感兴趣的人,如果两个投影点都位于穿过原点的一条直线上,则它们是全等的。)</p>
<pre><code>class Point(object):
def __init__(self, a, b, c):
self.coords = [ a, b, c ]
def congruent(self, other):
ratio = 0
for i in range(3):
if self.coords[i] != 0 and other.coords[i] != 0:
if ratio is 0:
ratio = other.coords[i] / self.coords[i]
elif ratio != other.coords[i] / self.coords[i]:
return False
elif self.coords[i] != 0 or other.coords[i] != 0:
return False
return True
</code></pre>
<p>我是Python新手,但我知道通常有一种“Python”方法来完成所有事情。考虑到这一点,我该如何使它更具可读性?在</p>