Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: classes

Reply
Thread Tools

Re: classes

 
 
Chris Angelico
Guest
Posts: n/a
 
      10-24-2012
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Classes within classes David ASP .Net 2 07-22-2005 07:13 PM
What is the difference between nested classes and inner classes ? Razvan Java 5 07-27-2004 07:59 PM
Modifiers applied to attributes, local variables, member functions, classes and inncer classes ! Razvan Java 11 07-17-2004 08:57 PM
Can I using reflection to get all child classes or classes undera package dynamically? Carfield Yim Java 1 05-31-2004 05:33 PM
How to access inner classes variables & methods from outer classes lonelyplanet999 Java 1 11-13-2003 01:54 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57