09/07/22 04:21:34
>>804
$ cat test01.py
class MyClass:
def __len__(self):
return 'Hello'
obj = MyClass()
print obj.__len__()
print len(obj)
$ python test01.py
Hello
Traceback (most recent call last):
File "test02.py", line 6, in <module>
print len(obj)
TypeError: __len__() should return an int