1# test subclassing a native type and overriding __init__ 2 3# overriding list.__init__() 4class L(list): 5 def __init__(self, a, b): 6 super().__init__([a, b]) 7print(L(2, 3)) 8 9# inherits implicitly from object 10class A: 11 def __init__(self): 12 print("A.__init__") 13 super().__init__() 14A() 15 16# inherits explicitly from object 17class B(object): 18 def __init__(self): 19 print("B.__init__") 20 super().__init__() 21B() 22 23# multiple inheritance with object explicitly mentioned 24class C: 25 pass 26class D(C, object): 27 def __init__(self): 28 print('D.__init__') 29 super().__init__() 30 def reinit(self): 31 print('D.foo') 32 super().__init__() 33a = D() 34a.__init__() 35a.reinit() 36 37# call __init__() after object is already init'd 38class L(list): 39 def reinit(self): 40 super().__init__(range(2)) 41a = L(range(5)) 42print(a) 43a.reinit() 44print(a) 45