www.example.com中的基类和内部子类c2base.py
class C2Methods(object):
_instruction = {}
_request = {}
_paramter = {}
_data = {}
_responsedata = {}
def init(self, instruction, request, parameter, data):
_instruction = instruction
_request = request
_paramter = parameter
_data = _data
def execute(self, instruction, request, parameter, data):
print('execute')
_responsedata = {}
return (_responsedata)
class InternalSubclass(C2Methods):
pass
并在相邻的文件www.example.com中testc2subclass.py
from c2base import C2Methods
class TestC2Subclass(C2Methods):
def execute(self, instruction, request, parameter, data):
print('TestC2Subclass.execute()')
_responsedata = {}
return (_responsedata)
在尝试使用它时,我写了以下内容
c2subclasses = c2base.C2Methods.__subclasses__()
print('XXXXXXXXXXXXXXXXXXXXXXX c2base subclasses', c2subclasses)
for cls in c2subclasses:
if executeScript == cls.__name__:
responsedata = {}
responsedata = cls.execute(cls, instruction_row, request, {}, {})
控制台仅显示内部子类... executeScript = TestC2Subclass ++++++++++++++ executeScript ++++++++++++++ XXXXXXXXXXXXXXXXXXXXXXX c2base subclasses [<class 'correlator.api.methods.c2base.InternalSubclass'>]
我有其他工作正常的基类和子类。我不明白为什么这只显示InternalSubclass。
1条答案
按热度按时间euoag5mw1#
是的,John发现问题是这些类尚未导入。