我有一节课
class Instruction(NamedTuple):
function: str
argument_register_1: str
argument_register_2: str
result_register: str
以及扩展它的类:
class OrderedInstruction(Instruction):
order: int
@classmethod
def from_instruction(cls, instruction: Instruction, order: int):
return cls(instruction.function,
instruction.argument_register_1,
instruction.argument_register_2,
instruction.result_register,
order)
但问题是当我试图调用OrderedInstruction.from_instruction(instruction, 0)
时,我得到了异常
TypeError: __new__() takes 5 positional arguments but 6 were given
我不知道为什么。我无法调试它,因为我没有看到对__new__
的调用。谁能告诉我如何创建/使用OrderedInstruction.from_instruction(instruction, number)
目前没有回答
相关问题 更多 >
编程相关推荐