我有以下代码:不能分配到函数调用(Python)的
class Quadratic:
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
def function(self, x):
self.F(x) = a*(x**2) + b*x + c
return F(x)
def table(self, lower, upper, varz):
inc = np.absolute(upper-lower)/varz
print inc
for i in range(0 , varz - 1):
self.F(lower)
lower = lower + inc
#lower bound,upper bound, number of values
def roots():
x1 = (-b + math.sqrt(b**2 - 4*a*c))/(2*a)
x2 = (-b - math.sqrt(b**2 - 4*a*c))/(2*a)
return x1, x2
def dump(self):
print self.n
每当我尝试运行此脚本,我得到以下几点:
line 15
self.F(x) = a*(x**2) + b*x + c
SyntaxError: can't assign to function call
任何帮助或想法将不胜感激。
有什么解释?你不能分配给一个函数调用。如果你想***定义一个函数,使用'def'或'lambda'。 – MattDMo 2015-04-01 21:46:56
什么是'F'?目前还不清楚你想要做什么。 – frnhr 2015-04-01 21:47:28
什么是'self.F(x)'? – 2015-04-01 21:49:17