Newbie question: Strange TypeError
Tim Isakson
loiosh13 at yahoo.com
Mon Jul 7 00:04:32 EDT 2003
Howdy,
I'm a new python programmer - new to python, not so much to programming -
my background was mainly C, with some C++, but it's rusty.
I'm learning python to try and get back into some coding,
and am running into a problem - I'm writing a calculator in python and
wxPython as an exercise to learn both, and the following problem is
leaving me baffled.
I have an event handler, and it's getting called fine - but within the
event handler, I'm calling a class method, HandleInput. The definition
and call are shown below:
def HandleInput(self, input):
if self.results.GetValue() == "0":
return input
elif newVal == True:
return input
else:
tmpVal = self.results.GetValue() + input
return tmpVal
def OnButton1(self,e):
tmpVal = self.HandleInput(self, "1")
self.results.SetValue(tmpVal)
The call to HandleInput is made, but I get the following error:
Calling HandleInput(self, '1')
Traceback (most recent call last):
File "pycalc.py", line 115, in OnButton1
tmpVal = self.HandleInput(self, "1")
TypeError: HandleInput() takes exactly 2 arguments (3 given)
So far as I can tell, the offending call *IS* calling HandleInput with 2
arguments, but the interpreter obviously thinks different, and I'm at a
loss as to why that might be.
I'm sure I'm doing something odd and not noticing, and I'd appreciate any
help you can provide!
Thanks in advance,
Tim
More information about the Python-list
mailing list