Re: classes

Discussion in 'Python' started by Chris Angelico, Oct 24, 2012.

  1. 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 <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
     
    Chris Angelico, Oct 24, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David

    Classes within classes

    David, Jul 21, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    4,952
    David
    Jul 22, 2005
  2. lonelyplanet999
    Replies:
    1
    Views:
    2,227
    VisionSet
    Nov 13, 2003
  3. Carfield Yim
    Replies:
    1
    Views:
    1,438
    Andrew Thompson
    May 31, 2004
  4. Razvan
    Replies:
    11
    Views:
    921
    Andrew Thompson
    Jul 17, 2004
  5. Razvan
    Replies:
    5
    Views:
    11,311
    Dale King
    Jul 27, 2004
Loading...

Share This Page