noob question: "TypeError" wrong number of args
Fredrik Lundh
fredrik at pythonware.com
Mon May 1 07:44:12 EDT 2006
Holger wrote:
> Tried searching for a solution to this, but the error message is so
> generic, that I could not get any meaningfull results.
>
> Anyways - errormessage:
> ----------------------------------------------------
> TypeError: addFile() takes exactly 1 argument (2 given)
> ----------------------------------------------------
>
> The script is run with two args "arg1" and "arg2":
> ----------------------------------------------------
> import sys
>
> class KeyBase:
> def addFile(file):
> print "initialize the base with lines from this file"
when defining your own classes, you must spell out the "self"
argument in your method definitions:
def addFile(self, file):
print "initialize the base with lines from this file"
see:
http://pyfaq.infogami.com/what-is-self
</F>
More information about the Python-list
mailing list