Python Forum

Full Version: Help in Class declaration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am new to Python.
I have written a class for declaration of a parabola. When i am trying to access the class it is showing the error " 'int' object has no attribute 'x' ".
Please help with this code.
Thanks

class Parabola:
    def __init__(self,c0,c1,c2):
        self.c0=c0
        self.c1=c1
        self.c2=c2
        

    def __call__(self,x):
        return self.c2*x**2+self.c1.x+self.c0

    def table(self,L,R,n):
        s=''
        import numpy as np
        for x in np.linspace(L,R,n):
            y=self(x)
            s+='%12g%12g\n'%(x,y)
            return s



p=Parabola(1,-2,2)
p1=p(x=2)
print(p.table(0,2,10))
Line 9 is wrong:
self.c1.x