相关疑难解决方法(0)

调用元类库时出错:function()参数1必须是代码,而不是str

我今天早些时候试图将threading.Condition子类化,但它没有成功.当我尝试子类化threading.Condition类时,这是Python解释器的输出:

>>> import threading
>>> class ThisWontWork(threading.Condition):
...     pass
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Error when calling the metaclass bases
    function() argument 1 must be code, not str
Run Code Online (Sandbox Code Playgroud)

有人可以解释这个错误吗?谢谢!

python inheritance metaclass class

43
推荐指数
3
解决办法
5万
查看次数

标签 统计

class ×1

inheritance ×1

metaclass ×1

python ×1