So I've been working to replace PHP with Python in my career for a bit. So I'm using WebPy with WSGI in apache, and all is working well, but I'm still learning the language, and can't find a simple explanation for this. So, while messing around, trying to get other classes methods to work in other classes, I came across some instructions that showed the first class being instantiated with (object) appended to the class name. It turns out that this works and lets me pass data through to that other class. Can someone tell me why this code will work?
And by work, I mean, it appears to me that if the first class doesn't specify (object) during its definition, then data can't be passed into that class? Is this right?
class MyClass(object):
def function1(self, num1, num2):
return num1 + num2
class index:
def GET(self):
form = web.input()
num1 = form.number1
num2 = form.number2
MyClass.function1(num1, num2)
I'm really trying to understand this. I mean it's great that I have it working (this is a code sample, not my actual project), but it will help if I understand WHY it's working. Thanks, I'm sure this is probably an easy question.