这样也许更清除
self.numbers = L
print 'self.numbers is list?',isinstance(self.numbers,list)
print len(L)
def __str__(self):
t = str(self.numbers)
print 'self.numbers now is str?',isinstance(t,str)
print len(t)
return t
__repr__ = __str__
def __len__(self):
return len(self.numbers)
结果:
self.numbers is list? True
10
self.numbers now is str? True
33
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
10