title: Can't set attributes on instance of "object" class
body: <p>So, I was playing around with Python while answering <a href="https://stackoverflow.com/questions/1528932/how-to-create-inline-objects-with-properties-in-python/">this question</a>, and I discovered that this is not valid:</p>
  <pre><code>o = object()
  o.attr = 'hello'
  </code></pre>
  <p>due to an <code>AttributeError: 'object' object has no attribute 'attr'</code>. However, with any class inherited from object, it is valid:</p>
  <pre><code>class Sub(object):
      pass
  
  s = Sub()
  s.attr = 'hello'
  </code></pre>
  <p>Printing <code>s.attr</code> displays 'hello' as expected. Why is this the case? What in the Python language specification specifies that you can't assign attributes to vanilla objects?</p>
  <hr />
  <p><sub>For other workarounds, see <a href="https://stackoverflow.com/questions/2827623">How can I create an object and add attributes to it?</a>.</sub></p>