V
vsoler
I have the following script:
class TTT(object):
def duplica(self):
self.data *= 2
def __init__(self, data):
self.data = data
TTT.duplica(self.data)
def __str__(self):
return str(self.data)
print
obj=TTT(7)
print obj
And I want 14 printed (twice 7)
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?
class TTT(object):
def duplica(self):
self.data *= 2
def __init__(self, data):
self.data = data
TTT.duplica(self.data)
def __str__(self):
return str(self.data)
obj=TTT(7)
print obj
And I want 14 printed (twice 7)
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?