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


Groups > comp.lang.python > #32033

Re: classes

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'argument': 0.04; 'arguments': 0.07; '__init__': 0.09; 'ignoring': 0.09; 'typeerror:': 0.09; '24,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'given)': 0.16; 'oct': 0.16; 'prog': 0.16; 'twice.': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; '(most': 0.27; 'possibly': 0.27; '???': 0.27; 'message-id:@mail.gmail.com': 0.27; 'error': 0.30; 'file': 0.32; 'print': 0.32; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'self': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'add': 0.36; 'but': 0.36; 'should': 0.36; 'being': 0.37; 'why': 0.37; 'passed': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'takes': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'first': 0.61; 'saving': 0.72
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=vmYGp2e0GuhIsK5WOSqFCqLVWkxzKNYyIr5MIb866/Q=; b=vJ+OnxE4r+qk0z2WHWH4x/A8XspBMzZ6Cl26M2thnv8wvQ8dwd9+4ElIOhYmZd1Ew8 EvFuhIz4DE8wz+rc8X+z2qkN5HEwQUiUKuh2hdjmuZkn3LfpfJ6i8X347TYqiMA9PgLz 4PwHsmr5qgmU+OY4J03BeGDshxDBTEq/v0bR9CDDEbx5FP+5O59tg+qExvnfaa/n13Ru 8CQYcMdBFshhqnEC8fMxsvoQlU/ONgo0/RKlwPRdoDlghVuEFXXmPKm/BSGDAvRaQyYL T85DLiIDcmiRNw0AKNpqdZi2G70Y/ZHjMVjOz+lzmkYhmbvetETPXex1VvhwsJWSTaon pPAw==
MIME-Version 1.0
In-Reply-To <CAFqGZRE1LbAgoOCAKuynYBw4Rj6++p+misZrsXmv1nwivHuNwg@mail.gmail.com>
References <CAFqGZRE1LbAgoOCAKuynYBw4Rj6++p+misZrsXmv1nwivHuNwg@mail.gmail.com>
Date Wed, 24 Oct 2012 23:39:38 +1100
Subject Re: classes
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.2756.1351082388.27098.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351082388 news.xs4all.nl 6966 [2001:888:2000:d::a6]:37586
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32033

Show key headers only | View raw


On Wed, Oct 24, 2012 at 11:11 PM, inshu chauhan <insideshoes@gmail.com> wrote:
> print " Adding twice of %4.2f gives " % (y.addtwice())
>
>
> Error is :
>
> Traceback (most recent call last):
>   File "Z:\learning Python\learn5.py", line 35, in <module>
>     print " Adding twice of %4.2f gives " % (y.addtwice())
> TypeError: addtwice() takes exactly 2 arguments (1 given)
>
> why the prog is having this error with self nd x as arguments ???

The first argument is 'self', which is being passed y, but you also
need to pass it a value to add twice. You're ignoring the argument to
__init__ so I don't know what your purpose is, but possibly you should
be saving that into self somewhere??

ChrisA

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


Thread

Re: classes Chris Angelico <rosuav@gmail.com> - 2012-10-24 23:39 +1100

csiph-web