Python showing error - object name not defined

The Python interpreter shows a NameError when using an 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 could not remove this error. Did I miss something?

+5
source share
1 answer

objectmust be lowercase. Try

>>> class test(object): pass

In Python 3.x, you can also just leave it:

>>> class test: pass

(In 2.x, you should not do this until you are ready to confront the monster of the classical classes )

+14
source

All Articles