如何重新加载python包?TypeError:super(type,obj):obj必须是类型的实例或子类型

2024-10-01 17:34:39 发布

您现在位置:Python中文网/ 问答频道 /正文

在重新加载我刚刚更新的分支模块后,出现以下错误:TypeError: super(type, obj): obj must be an instance or subtype of type,直到我以正确的顺序重新加载从属模块

我有这种依赖关系:

weird
  |_  __init__.py
  |_  A.py
  |_  B.py
  |_  C.py

A.py:

import B

B.py:

import C
class Baleze(C.WeshGros):
    def __init__(self):
        super(Baleze, self).__init__()

C.py:

class WeshGros(object):
    def __init__(self):
        super(WeshGros, self).__init__()
        print('nothing')

>>>import A

现在用C.py中的print('reallyNothing')替换print('nothing')

>>>reload(C)

>>>reload(A)

TypeError: super(type, obj): obj must be an instance or subtype of type

我不想手动重新加载B,因为我的树依赖项很大。解决这个问题的最佳实践是什么


Tags: 模块instancepyimportselfanobjinit

热门问题