Calling a class method

Andreas Waldenburger usenot at geekmail.INVALID
Sat Apr 17 10:06:09 EDT 2010


On Sat, 17 Apr 2010 15:44:56 +0200 Andreas Waldenburger
<usenot at geekmail.INVALID> wrote:

> On Sat, 17 Apr 2010 06:09:21 -0700 (PDT) vsoler
> <vicente.soler at gmail.com> wrote:
> 
> > I got the following error:
> > TypeError: unbound method duplica() must be called with TTT instance
> > as first argument (got int instance instead)
> > 
> > What am I doing wrong?
> 
> Not reading the error message.
> 
> [snip rest of my response]
> 

No wait. I misread your code. Sorry.

There are two problems with this line:

    TTT.duplica(self.data)

It should read

    self.duplica()

Then it should work.

It may be a nice exercise for you to work out why the code needs to be
changed like that. On top of that, perhaps you'd like to think about
why you thought it should be "TTT.duplica(self.data)". Comparing that
to the correct way should be very beneficial to you understanding of
the matter. If you like you can post your thoughts here to verify them.

All my comments about reading tutorials and posting to python-tutor
still apply, however.

[Sidenote: What's that lone print statement above "obj=TTT(7)"
supposed to do?]

/W

-- 
INVALID? DE!




More information about the Python-list mailing list