Python interpreter is showing NameError on using Object.
>>> class test(Object): pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Object' is not defined
Python version is 2.7.3.
I haven't been able to remove this error. Am I missing something here?
What is a NameError? A NameError is raised when you try to use a variable or a function name that is not valid. In Python, code runs from top to bottom. This means that you cannot declare a variable after you try to use it in your code.
This error has the following cause and solution: You used an Option Explicit statement to require the explicit declaration of variables, but you used a variable without declaring it. Explicitly declare the variable, or change the spelling of the variable to match that of the intended variable.
object
must be lower-case. Try
>>> class test(object): pass
In Python 3.x, you can also just leave it out:
>>> class test: pass
(In 2.x, you should not do that until you are ready to face the monstrosity of classic classes)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With