TypeError: __init__() takes exactly 1 positional argument (2 given)

Ian Kelly ian.g.kelly at gmail.com
Mon May 16 00:12:47 EDT 2011


On Sun, May 15, 2011 at 9:53 PM, Gnarlodious <gnarlodious at gmail.com> wrote:
> class GnomonBase(object):
>    def __init__(self, bench):
>        # do stuff
>
> But all I get is:
> TypeError: __init__() takes exactly 1 positional argument (2 given)
>
> I don't understand, I am only sending one variable. What does it think
> I am sending two?

Usually this error means that you forgot to include "self" in the
method signature.  As a result it receives two arguments (self and
bench) but only has one defined (bench).

The snippet you posted looks correct, though.  It might be easier to
help if you posted the actual code.  Also the full stack trace might
be helpful.



More information about the Python-list mailing list