Given below example, I want to figure out what causes the exception of
"NameError: global name 'MATRIX' is not defined" when executing test.fun1().
Thanks a lot.
class test:
MATRIX = []
@staticmethod
def fun1():
global MATRIX
test.fun2(MATRIX)
@staticmethod
def fun2(MATRIX):
MATRIX.append(2)
test.fun1()
print test.MATRIX
Your
MATRIXis not global, it’s a class attribute, try like this: