在ipython shell中重新加载时出现/ python 2.7 /错误:
TypeError:super(type,obj):obj必须是类型的实例或子类型
我已经读过了:
https://thingspython.wordpress.com/2010/09/27/another-super-wrinkle-raising-typeerror/
但是它不起作用!
问题是我不使用 __ init __ ,而是使用 __ new __ ,因为我正在扩展numpy.ndarray
class myClass(np.ndarray):
def __new__(cls, nbits=NBITS) :
..............
obj = super(myClass, cls).__new__(cls, shape=(nbits,), buffer=buf, dtype=DTYPE)
..............
任何解决此问题的方法都会使Mr.Mr疯狂,我必须退出并反复启动ipython 每次小改变
obj = super(myClass, cls).__new__(cls, shape=(nbits,), buffer=buf, dtype=DTYPE)
TypeError: super(type, obj): obj must be an instance or subtype of type