title: Python Language Question: attributes of object() vs Function
body: <p>In python, it is illegal to create new attribute for an object instance like this</p>
  
  <pre><code>&gt;&gt;&gt; a = object()
  &gt;&gt;&gt; a.hhh = 1
  </code></pre>
  
  <p>throws </p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  AttributeError: 'object' object has no attribute 'hhh'
  </code></pre>
  
  <p>However, for a function object, it is OK.</p>
  
  <pre><code>&gt;&gt;&gt; def f():
  ...   return 1
  ...
  &gt;&gt;&gt; f.hhh = 1
  </code></pre>
  
  <p>What is the rationale behind this difference?</p>