Python Forum

Full Version: Error in code NameError: name ' ' is not defined
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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?
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.
Pages: 1 2