"TypeError: missing 1 required positional argument" Instance error
"TypeError: missing 1 required positional argument" Instance error
我有两个 classes,在第一个中我创建了第二个 class 的实例并执行了第二个 class 的方法,该方法启动了一个过程。
t1.py
test = "t1"
def executeBase():
base = baseNode.BaseNode()
baseNode.BaseNode.executeBase(test, base) #error
和baseNode.py
class BaseNode():
def __init__(self):
self.eui48 = "01:00:00:00:00:00"
self.port = 7919
def executeBase(self, test, base):
#I execute here a process
我收到行错误 (#error)。
File "/testbench/testbenchPython/test/t1.py", line 20, in executeBase
baseNode.BaseNode.executeBase(test, base)
TypeError: executeBase() missing 1 required positional argument: 'base'
这不是可以吗?如果是,问题是什么,我该如何纠正?
我试过以不同的方式传递参数,但没有找到解决方案。
非常感谢!
在这种情况下
def executeBase():
base = baseNode.BaseNode()
baseNode.BaseNode.executeBase(test, base) #error
我猜 executeBase() 函数正在寻找自己!而不是 baseNode.BaseNode.executeBase(test, base) #error
这一行,这可能有效 base.executeBase(test,base)
您应该在您的 instance.Try 上调用 executeBase
:
def executeBase():
base = baseNode.BaseNode()
base.executeBase(test, base)
我有两个 classes,在第一个中我创建了第二个 class 的实例并执行了第二个 class 的方法,该方法启动了一个过程。
t1.py
test = "t1"
def executeBase():
base = baseNode.BaseNode()
baseNode.BaseNode.executeBase(test, base) #error
和baseNode.py
class BaseNode():
def __init__(self):
self.eui48 = "01:00:00:00:00:00"
self.port = 7919
def executeBase(self, test, base):
#I execute here a process
我收到行错误 (#error)。
File "/testbench/testbenchPython/test/t1.py", line 20, in executeBase
baseNode.BaseNode.executeBase(test, base)
TypeError: executeBase() missing 1 required positional argument: 'base'
这不是可以吗?如果是,问题是什么,我该如何纠正? 我试过以不同的方式传递参数,但没有找到解决方案。
非常感谢!
在这种情况下
def executeBase():
base = baseNode.BaseNode()
baseNode.BaseNode.executeBase(test, base) #error
我猜 executeBase() 函数正在寻找自己!而不是 baseNode.BaseNode.executeBase(test, base) #error
这一行,这可能有效 base.executeBase(test,base)
您应该在您的 instance.Try 上调用 executeBase
:
def executeBase():
base = baseNode.BaseNode()
base.executeBase(test, base)