Python Forum
Error in code NameError: name ' ' is not defined
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error in code NameError: name ' ' is not defined
#11
By using dot format you are referring to attributes of objects. To do so, the object must be defined first. Looking at the code, I don’t see why you would choose to do it this way, and suggest just using regular variables. Is there a specific reason to use objects and dot notation?
Reply
#12
Also, naming: numb obviously seems short for "number". Why then would a number have attributes (or properties) x, y and i? That doesn't make much sense. If your program, say, was to do with geometry, then you might have a variable called point and it would be natural to read point.x, point.y, point.z as the coordinates of that point.

The point: choose names (and data structures) that actually reflect what the thing being named is and is used for. It helps you and others to read and understand the code.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation NameError: name 'score' is not defined - Help? MrKnd94 13 4,666 Mar-06-2023, 10:54 PM
Last Post: deanhystad
  How to correct the NameError: name 'xx' is not defined? vokoyo 5 11,366 Feb-17-2021, 05:55 AM
Last Post: delonbest
  NameError: name 'os' is not defined, & load_files(sys.argv[1]) AryaIC 3 4,747 Nov-07-2020, 07:45 PM
Last Post: jefsummers
  NameError: name 'print_string' is not defined jamie_01 2 2,056 Jun-11-2020, 05:27 AM
Last Post: buran
  "NameError: name 'catName1' is not defined tofif 3 5,679 Jun-24-2019, 06:05 AM
Last Post: perfringo
  NameError x not defined Bruizeh 5 5,319 Feb-27-2019, 10:59 AM
Last Post: Larz60+
  NameError: name 'mailbox_list' is not defined pythonnewb 2 4,780 Aug-06-2017, 09:31 PM
Last Post: pythonnewb

Forum Jump:

User Panel Messages

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