You can instantiate a class by declaring a variable and calling the class as if it were a function:
x = mystuff() print x.average(9,18,27)
However, this will not work with the code you gave us. When you call a class method for a given object (x), it always passes a pointer to the object as the first parameter when calling the function. Therefore, if you run your code right now, you will see this error message:
TypeError: average() takes exactly 3 arguments (4 given)
To fix this, you will need to modify the definition of the middle method to accept four parameters. The first parameter is a reference to the object, and the remaining 3 parameters will be for three numbers.
Ryan Dec 28 '08 at 23:48 2008-12-28 23:48
source share