subclass_native_specmeth.py 282 B

123456789101112131415161718
  1. # Test calling non-special method inherited from native type
  2. class mylist(list):
  3. pass
  4. l = mylist([1, 2, 3])
  5. print(l)
  6. print([e for e in l])
  7. class mylist2(list):
  8. def __iter__(self):
  9. return iter([10, 20, 30])
  10. l = mylist2([1, 2, 3])
  11. print(l)
  12. print([e for e in l])