The following code runs nicely with no error:
class A(object):
pass
a = A()
a.attr = True
Running the following code:
o = object()
o.attr = True
raises the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-54-9fd7259047d0> in <module>()
1 o = object()
----> 2 o.attr = True
AttributeError: 'object' object has no attribute 'attr'
Why? Class A
inherited from object
, so why do I get an error when I create an object from class object
?