This is my code. I am a beginner in Python. I try to call func in func2 and func3of class Apple. After I Google my problem, I found that it could work by using @staticmethod, but I would like to figure out another method without using @staticmethod. In func3, I didn't use @staticmethod, so it has a error: print(mycall.func3(3) )
TypeError: func3() takes exactly 1 argument (2 given)
Does anyone know how to fix my problem? Thank you.
class mango:
def func(self):
a=8
b=9
return a+b
class Apple:
@staticmethod
def func2(x,y):
temp=mango()
c=temp.func()
z=x+y+c
return z
def func3(val):
temp = mango()
d = temp.func()
output = d + val
return output
if __name__ == '__main__':
print "Hello, Python!"
a = []
b =[]
ans = Test(a,b)
print(ans.cc)
mycall = Apple()
print(mycall.func2(2,3))
print(mycall.func3(3) )