为什么gcd函数不能放在rational类里面定义呢?
class Rational(object):
def __init__(self, p, q):
self.p = p
self.q = q
def gcd(a,b):
if b==0:
return a
return gcd(b,a%b)
class Rational(object):
def __init__(self, p, q):
self.p = p
self.q = q
def gcd(a,b):
if b==0:
return a
return gcd(b,a%b)
2015-05-20
举报