Page 1 of 1

Variable Not being Defined

Posted: Tue Jun 11, 2019 11:44 pm
by Zsapp01
I created a simply timer variable but it keeps on saying the variable is not defined but i can not tell why, if someone can help the section of code is below, Thanks.

Code: Select all

def listen_rfid(self):
        global pin
        global accessLogId
        global counter      
        keys = "X^1234567890XXXXqwertzuiopXXXXasdfghjklXXXXXyxcvbnmXXXXXXXXXXXXXXXXXXXXXXX"
        dev = InputDevice('/dev/input/event3')
        rfid_presented = ""
        counter = 0
    while True:
        if counter == 1:
             dev = InputDevice('/dev/input/event2')
        else:
            dev = InputDevice('/dev/input/event3')

Re: Variable Not being Defined

Posted: Wed Jun 12, 2019 4:45 am
by rpdom
Well, at first glance it looks like your indentation is all over the place. Python doesn't like that.

Re: Variable Not being Defined

Posted: Wed Jun 12, 2019 7:25 am
by scotty101
Would also be helpful for you to share a more complete code example and the full error message that you receive. At the moment, we have no idea which variable is the problem.

Re: Variable Not being Defined

Posted: Wed Jun 12, 2019 7:30 am
by Andyroo
It may also help to see the output of

Code: Select all

xinput list
If it’s the event lines causing the issue.