【发布时间】:2018-11-03 12:40:34
【问题描述】:
更新:为了解决 Choregraphe 和 Python 的结合,我拒绝了使用 @classmethod 的想法。相反,当我想使用 MyClass 时,我会在 MyCustomClass 中引发 AlMemory 事件。
我阅读了很多关于 NameError 的帖子,但仍然找不到解决问题的方法。
我使用 Python 框为 Nao 编写了一个带有 Choregraphe 的程序。
我得到了以下内容:
class MyClass(GeneratedClass): #GeneratedClass is given
def __init__(self):
GeneratedClass.__init__(self)
@classmethod
def doSomething(cls, a):
print a
class myCustomClass():
def func(self):
MyClass.doSomething(a)
当从 myCustomClass 调用 func() 时,我在 MyClass 上得到了 NameError。
[ERROR] behavior.box :FMBox::createPythonModule:0 _Behavior__lastUploadedChoregrapheBehaviorbehavior_1275012824__root__test_1:用户类评估失败并出现以下错误: 未定义全局名称“MyClass”
我该如何解决这个问题?
【问题讨论】:
-
您应该将代码更新为标准的 4 个空格缩进。
-
doSomething方法定义在哪里? -
do也是 Python 中的关键字,请为此方法使用其他名称。 -
@Hitobat 不,不是。
-
最新状态:根据@Rarblack 的反馈,我将
self更改为cls。但是还是不行。
标签: python-2.7 class nao-robot pepper choregraphe