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: 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: References: Date: Wed, 24 Oct 2012 23:39:38 +1100 Subject: Re: classes From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Wed, Oct 24, 2012 at 11:11 PM, inshu chauhan 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 > 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