Python Forum
Translate to noob a Name Eroor message
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Translate to noob a Name Eroor message
#1
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?
Reply
#2
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':
Reply
#3
Ah... stupid me. So, no quotes on variables. Specific values require quotes of some sort.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  googletrans library to translate text language for using data frame is not running gcozba2023 0 1,222 Mar-06-2023, 09:50 AM
Last Post: gcozba2023
  BeautifulSoup - I can't translate html tags that contain <a href=..</a> OR <em></em> Melcu54 10 1,628 Oct-27-2022, 08:58 AM
Last Post: wavic
  How to Translate a python code written in Mac-OS to Windows? alexanderDennisEnviro500 2 2,698 Jul-31-2021, 08:36 AM
Last Post: Gribouillis
  Delimiters - How to skip some html tags from being translate Melcu54 0 1,647 May-26-2021, 06:21 AM
Last Post: Melcu54
  Translate this line of code please keystone76 2 2,630 Jan-31-2020, 11:15 PM
Last Post: keystone76
  translate \ to / ? Skaperen 4 2,505 Oct-01-2019, 06:05 AM
Last Post: Skaperen
  Heating program to translate from Basic to Python tommy2k19 12 5,958 May-21-2019, 08:16 AM
Last Post: tommy2k19
  translate this into python plz abrew132 3 3,897 Apr-12-2017, 10:42 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020