Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32033
| References | <CAFqGZRE1LbAgoOCAKuynYBw4Rj6++p+misZrsXmv1nwivHuNwg@mail.gmail.com> |
|---|---|
| Date | 2012-10-24 23:39 +1100 |
| Subject | Re: classes |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2756.1351082388.27098.python-list@python.org> (permalink) |
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
Re: classes Chris Angelico <rosuav@gmail.com> - 2012-10-24 23:39 +1100
csiph-web