【发布时间】:2011-02-17 23:27:39
【问题描述】:
不知何故,这在 Maya/Python 脚本编辑器中运行良好,但在我的模块代码中时会失败。有人有什么想法吗?
class ControlShape(object):
def __init__(self, *args, **kwargs):
print 'Inside ControlShape...'
class Cross(ControlShape):
def __init__(self, *args, **kwargs):
print 'Entering Cross...'
super(Cross, self).__init__(*args, **kwargs)
print 'Leaving Cross...'
x = Cross()
这给了我一个 TypeError: super(type, obj): obj must be an instance or subtype of type.
【问题讨论】:
-
粘贴到 ipython 中没有任何错误,确定你的程序中没有其他代码?
-
完整的回溯会很有帮助。此代码也适用于 CPython 2.6.5。
-
是的,问题是它在 Maya 模块中不起作用,我不明白。
-
错误消息暗示
self不是Cross的实例。有什么东西会反弹Cross吗?也许在您的代码或 Maya 中发生了一些事情,它用某种包装器替换了绑定到类的名称?完整的回溯会有所帮助:如果Cross确实是实际类的某种包装器,那么它应该显示在堆栈中。