1class mylist(list): 2 pass 3 4a = mylist([1, 2, 5]) 5# Test setting instance attr 6a.attr = "something" 7# Test base type __str__ 8print(a) 9# Test getting instance attr 10print(a.attr) 11# Test base type ->subscr 12print(a[-1]) 13a[0] = -1 14print(a) 15# Test another base type unary op 16print(len(a)) 17 18# Test binary op of base type, with 2nd arg being raw base type 19print(a + [20, 30, 40]) 20# Test binary op of base type, with 2nd arg being same class as 1st arg 21# TODO: Faults 22#print(a + a) 23 24def foo(): 25 print("hello from foo") 26 27try: 28 class myfunc(type(foo)): 29 pass 30except TypeError: 31 print("TypeError") 32 33# multiple bases with layout conflict 34try: 35 class A(type, tuple): 36 None 37except TypeError: 38 print('TypeError') 39