Python Forum

Full Version: Translate to noob a Name Eroor message
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What exactly does this mean?

Error:
Traceback (most recent call last): File "waveshare_init.py", line 22, in <module> if cmd == off: NameError: name 'off' is not defined
"off" is cmd = sys.argv[1] which should be an option an option when I run the script. no?
As written, the interpreter is looking for a variable named off. If you want to check for the string value, quotes are needed:

if cmd == "off":

# Or

if cmd == 'off':
Ah... stupid me. So, no quotes on variables. Specific values require quotes of some sort.