How Do You Troubleshoot the Python Error “NameError: name ” is not defined”?

Problem scenario
You are trying to run a Python program with a class. You get this message:

File "", line 11, in
class Building(param1, param2):
NameError: name 'param1' is not defined

What should you do?

Use the word "object" instead of one or more parameters that you are passing in the parentheses () of the class.

Change "class Building(param1, param2):" to "class Building(object):".

For more information on why this works, see this posting:

Leave a comment

Your email address will not be published. Required fields are marked *