Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5477

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

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'arguments': 0.05; 'snippet': 0.07; 'though.': 0.07; 'positional': 0.09; 'sun,': 0.09; 'pm,': 0.11; 'wrote:': 0.14; 'defined': 0.15; 'subject:() ': 0.16; 'two?': 0.16; 'variable.': 0.16; '\xa0def': 0.16; 'argument': 0.16; 'stack': 0.16; 'code.': 0.18; 'stuff': 0.18; 'trace': 0.19; 'header:In-Reply-To:1': 0.22; 'posted': 0.22; 'correct,': 0.23; 'received:209.85.161.46': 0.26; 'received:mail- fx0-f46.google.com': 0.26; 'message-id:@mail.gmail.com': 0.28; 'looks': 0.28; 'received:209.85.161': 0.29; 'error': 0.29; 'class': 0.29; 'forgot': 0.29; 'receives': 0.29; 'helpful.': 0.31; 'typeerror:': 0.31; 'does': 0.31; 'actual': 0.31; 'to:addr:python- list': 0.32; 'usually': 0.36; 'think': 0.36; 'two': 0.37; 'received:209.85': 0.37; 'exactly': 0.37; 'received:google.com': 0.38; 'but': 0.38; 'help': 0.39; 'to:addr:python.org': 0.39; 'subject: (': 0.39; 'received:209': 0.39; 'takes': 0.40; 'include': 0.40; 'header:Received:5': 0.40; 'might': 0.40; '2011': 0.62; 'full': 0.62; 'signature.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=ftUd5gTKNuPZnNSjZ1uE6j4hhRBsE3j67jXqwyBSdjY=; b=T2PauWh/waZVGb9cWqN12NLpVFYV0dD8NWYc6UwBGrZybj51SIodr6ZC378zoqAZLQ M2/R9K5St6fnFYV8dz3czQ75NmEonds2l7MtxtKgig1PVdrEtLFaGhOPPIuviqH6RsMM HT2YYGYK0Faanyx5BqazxHqlJ40r/TVVgbL+A=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=Y1Kd5VRW4O+OEzIILDiGAnlKLVsO89E/Wbjv9IC4Rt69Uh+iZeaW0dH2XbOuWeCQPz X5LzaOccJTtdR2jiB7zVbrW6HSy9Tu6oF1chPVV6jAbG0tGDqiAvEAyJi9gtI5/SAo1V TyW1IG5qvt9MF7oxVcmteRvJjnTutHCsxwPes=
MIME-Version 1.0
In-Reply-To <fb474512-8d88-424b-b7ef-01e20d04478e@h36g2000pro.googlegroups.com>
References <fb474512-8d88-424b-b7ef-01e20d04478e@h36g2000pro.googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Sun, 15 May 2011 22:12:47 -0600
Subject Re: TypeError: __init__() takes exactly 1 positional argument (2 given)
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1618.1305519199.9059.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 82.94.164.166
X-Trace 1305519199 news.xs4all.nl 81475 [::ffff:82.94.164.166]:55733
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:5477

Show key headers only | View raw


On Sun, May 15, 2011 at 9:53 PM, Gnarlodious <gnarlodious@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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

TypeError: __init__() takes exactly 1 positional argument (2 given) Gnarlodious <gnarlodious@gmail.com> - 2011-05-15 20:53 -0700
  Re: TypeError: __init__() takes exactly 1 positional argument (2 given) harrismh777 <harrismh777@charter.net> - 2011-05-15 22:59 -0500
  Re: TypeError: __init__() takes exactly 1 positional argument (2 given) Chris Rebert <clp2@rebertia.com> - 2011-05-15 21:10 -0700
  Re: TypeError: __init__() takes exactly 1 positional argument (2 given) Ian Kelly <ian.g.kelly@gmail.com> - 2011-05-15 22:12 -0600
    Re: TypeError: __init__() takes exactly 1 positional argument (2 given) Gnarlodious <gnarlodious@gmail.com> - 2011-05-15 21:30 -0700
      Re: TypeError: __init__() takes exactly 1 positional argument (2 given) Chris Rebert <clp2@rebertia.com> - 2011-05-15 21:44 -0700
        Re: TypeError: __init__() takes exactly 1 positional argument (2 given) Gnarlodious <gnarlodious@gmail.com> - 2011-05-15 21:53 -0700
      Re: TypeError: __init__() takes exactly 1 positional argument (2 given) Ian Kelly <ian.g.kelly@gmail.com> - 2011-05-15 22:54 -0600
        Re: TypeError: __init__() takes exactly 1 positional argument (2 given) Gnarlodious <gnarlodious@gmail.com> - 2011-05-15 22:08 -0700
  Re: TypeError: __init__() takes exactly 1 positional argument (2 given) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-16 04:31 +0000

csiph-web