Код: Выделить всё
class My(object):
def __len__(self):
return 6
a = My()
print(len(a))
Код: Выделить всё
class My2(object):
pass
b = My2()
b.__len__ = lambda x: 6
print(len(b))
Код: Выделить всё
TypeError: object of type 'My2' has no len()Подробнее здесь: https://stackoverflow.com/questions/479 ... y-expected
Мобильная версия