Zsapp01
Posts: 4
Joined: Tue May 28, 2019 5:57 pm

Variable Not being Defined

Tue Jun 11, 2019 11:44 pm

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')

User avatar
rpdom
Posts: 17275
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Variable Not being Defined

Wed Jun 12, 2019 4:45 am

Well, at first glance it looks like your indentation is all over the place. Python doesn't like that.
Unreadable squiggle

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: Variable Not being Defined

Wed Jun 12, 2019 7:25 am

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.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Andyroo

Re: Variable Not being Defined

Wed Jun 12, 2019 7:30 am

It may also help to see the output of

Code: Select all

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

Return to “Python”