Skip to content
Advertisement

Name Error- name “xxxxx” is not defined with the objects – Python [closed]

Am very new to Python programming.Which am getting the naming error in my function with the object but without the object it works fine.

Hope to get a help from the community.

JavaScript

Advertisement

Answer

The minimal problem with your code is that your definition of the class clsCalcScore_Ex6 is incomplete. If you add a single line to fully define the class, like this, your code will work:

JavaScript

If what you want to do is move your functions into the class as methods, then you have more work to do. Here’s what doing that correctly might look like:

JavaScript

Here’s another way that uses static methods and avoids you having to instantiate an instance of the class (note the removal of the first set of parens in the last line):

JavaScript

The second way is functionally identical to your original code. It just adds a namespace, placing most of your code under the name clsCalcScore_Ex6.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement