E
E
Egorian2018-03-26 13:24:01
Python
Egorian, 2018-03-26 13:24:01

Unresolved reference Python?

There is a declared variable previous_direction. I use it in a class function.

def change_direction(self,event):

        if event.keysym in self.mapping:

         if previous_direction==antidirections[event.keysym]:
          ....
         else:
         previous_direction=...
When I use this variable twice, an Unresolved reference error occurs. What to do in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
exr, 2018-03-26
@Egorian

Apparently the previous_direction variable is initialized in the body of another function or the class itself, and is not visible to this one. Try self. previous_direction.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question