Update: to work around the combination of Choregraphe and Python, I rejected the idea of having @classmethod. Instead I raise AlMemory events in MyCustomClass when I want to make use of MyClass.
I read many posts on NameError but still couldn't find a solution to my problem.
I write a program with Choregraphe using the Python box for Nao.
I got the followings:
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)
When calling func() from myCustomClass, I got NameError on MyClass.
[ERROR] behavior.box :FMBox::createPythonModule:0 _Behavior__lastUploadedChoregrapheBehaviorbehavior_1275012824__root__test_1: User class evaluation failed with the error: global name 'MyClass' is not defined
How can I fix that?
As a start your
@methodand class structure is wrong.When I ran your code it says this :
Output:
Your class structure is completely wrong. If you want to pass a parameter, use
__init__method.If you are using
@methodclassyou should not passself, it iscls. Like in this example:In case if you are trying inheritance take this is an example how it should be.
Now all in one according to yours:
NOTE: I have used python 3.x.