I have a program like :
class ABC: q = {} def update: self.state = (xx,xx) global q if self.state in q: // do something I am getting the error :
"NameError: global name 'q' is not defined"
Im new to python and need some help.
I have a program like :
class ABC: q = {} def update: self.state = (xx,xx) global q if self.state in q: // do something I am getting the error :
"NameError: global name 'q' is not defined"
Im new to python and need some help.
You can move q outside of the class:
q = {} class ABC: def update: self.state = (xx,xx) global q if self.state in q: # do something pass or you can reference q as a class variable:
class ABC: q = {} def update: self.state = (xx,xx) if self.state in ABC.q: # do something pass