我试图继承xrange以启用整数列表的目标对象行为(可迭代和in运算符支持)。但我收到以下错误消息:
TypeError: Error when calling the metaclass bases
type 'xrange' is not an acceptable base type
有什么特别之处xrange?
另外,可能与那个问题无关,我注意到xrangehas not method __contains__。对于in操作,我的基本知识是,a in A相当于A. contains (a)。我错了,还是xrange有什么不同?
我不知道我是否应该将这些粘贴为两个单独的问题。提前道歉。