On Sat, Apr 17, 2010 at 11:09 PM, vsoler <span dir="ltr"><<a href="mailto:vicente.soler@gmail.com">vicente.soler@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

I have the following script:<br>
<br>
class TTT(object):<br>
    def duplica(self):<br>
        self.data *= 2<br>
    def __init__(self, data):<br>
        self.data = data<br>
        TTT.duplica(self.data)<br></blockquote><div><br>You're calling duplica with the class, and not by its object (self).<br><br>self.duplica()<br><br>will do what you want.<br><br>Cheers,<br>Xav<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


<br>
And I want 14 printed (twice 7)<br>
<br>
I got the following error:<br>
TypeError: unbound method duplica() must be called with TTT instance<br>
as first argument (got int instance instead)<br>
<br>
What am I doing wrong?<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>